END_TEST;
}
+
+
+int UtcDaliTypeInfoRegisterChildProperties03(void)
+{
+ TestApplication application;
+ TypeRegistry typeRegistry = TypeRegistry::Get();
+
+ tet_infoline( "Check registered child properties can be retrieved" );
+
+ auto customActorTypeInfo = typeRegistry.GetTypeInfo( typeid(CustomActor) );
+ auto myCustomTypeInfo = typeRegistry.GetTypeInfo( typeid(MyTestCustomActor) );
+ DALI_TEST_CHECK( customActorTypeInfo );
+ DALI_TEST_CHECK( myCustomTypeInfo );
+
+ const Property::Index WIDTH_SPECIFICATION( CHILD_PROPERTY_REGISTRATION_START_INDEX );
+ const Property::Index HEIGHT_SPECIFICATION( CHILD_PROPERTY_REGISTRATION_START_INDEX + 1);
+ const Property::Index MARGIN_SPECIFICATION( CHILD_PROPERTY_REGISTRATION_START_INDEX + 100);
+
+ ChildPropertyRegistration( customActorTypeInfo.GetName(), "widthSpecification", WIDTH_SPECIFICATION, Property::INTEGER );
+ ChildPropertyRegistration( customActorTypeInfo.GetName(), "heightSpecification", HEIGHT_SPECIFICATION, Property::INTEGER );
+ ChildPropertyRegistration( myCustomTypeInfo.GetName(), "marginSpecification", MARGIN_SPECIFICATION, Property::EXTENTS );
+
+ Property::IndexContainer indices;
+ myCustomTypeInfo.GetChildPropertyIndices( indices );
+
+ auto result = std::find( indices.Begin(), indices.End(), WIDTH_SPECIFICATION );
+ DALI_TEST_EQUALS( result != indices.End(), true, TEST_LOCATION );
+
+ result = std::find( indices.Begin(), indices.End(), HEIGHT_SPECIFICATION );
+ DALI_TEST_EQUALS( result != indices.End(), true, TEST_LOCATION );
+
+ result = std::find( indices.Begin(), indices.End(), MARGIN_SPECIFICATION );
+ DALI_TEST_EQUALS( result != indices.End(), true, TEST_LOCATION );
+
+ END_TEST;
+}
/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2018 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
baseImpl.GetPropertyIndices( indices );
}
- if ( ! mRegisteredProperties.empty() )
+ AppendProperties( indices, mRegisteredProperties );
+}
+
+void TypeInfo::GetChildPropertyIndices( Property::IndexContainer& indices ) const
+{
+ Dali::TypeInfo base = TypeRegistry::Get()->GetTypeInfo( mBaseTypeName );
+ if ( base )
+ {
+ const TypeInfo& baseImpl( GetImplementation( base ) );
+ baseImpl.GetChildPropertyIndices( indices );
+ }
+
+ AppendProperties( indices, mRegisteredChildProperties );
+}
+
+/**
+ * Append the indices in RegisteredProperties to the given index container.
+ */
+void TypeInfo::AppendProperties( Dali::Property::IndexContainer& indices,
+ const TypeInfo::RegisteredPropertyContainer& registeredProperties ) const
+{
+ if ( ! registeredProperties.empty() )
{
- indices.Reserve( indices.Size() + mRegisteredProperties.size() );
+ indices.Reserve( indices.Size() + registeredProperties.size() );
- const RegisteredPropertyContainer::const_iterator endIter = mRegisteredProperties.end();
- for ( RegisteredPropertyContainer::const_iterator iter = mRegisteredProperties.begin(); iter != endIter; ++iter )
+ for( auto&& elem : registeredProperties )
{
- indices.PushBack( iter->first );
+ indices.PushBack( elem.first );
}
}
}
#define __DALI_INTERNAL_TYPE_INFO_H__
/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2018 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Property::Type GetChildPropertyType( Property::Index index ) const;
/**
+ * Retrive the child indices into the given container.
+ * @param[in,out] indices The container to put the child indices into
+ */
+ void GetChildPropertyIndices( Property::IndexContainer& indices ) const;
+
+ /**
* Retrieve the default value of the property at the given index.
* @param[in] index The property index.
* @return The default property value at that index.
typedef std::vector< RegisteredPropertyPair > RegisteredPropertyContainer;
typedef std::vector< PropertyDefaultValuePair > PropertyDefaultValueContainer;
+
+ /**
+ * Append properties from registeredProperties onto indices.
+ * @param[in,out] indices The vector to append indices onto
+ * @param[in] registeredProperties The container to retrive indices from
+ */
+ void AppendProperties( Dali::Property::IndexContainer& indices,
+ const TypeInfo::RegisteredPropertyContainer& registeredProperties ) const;
+
+private:
+
std::string mTypeName;
std::string mBaseTypeName;
bool mCSharpType:1; ///< Whether this type info is for a CSharp control (instead of C++)
return GetImplementation(*this).GetChildPropertyType( index );
}
+void TypeInfo::GetChildPropertyIndices( Property::IndexContainer& indices ) const
+{
+ indices.Clear(); // We do not want to clear the container if called internally, so only clear here
+ GetImplementation(*this).GetChildPropertyIndices( indices );
+}
+
TypeInfo::TypeInfo(Internal::TypeInfo* internal)
: BaseHandle(internal)
{
void GetPropertyIndices( Property::IndexContainer& indices ) const;
/**
+ * @brief Retrieves all the child property indices for this type.
+ *
+ * @SINCE_1_3.20
+ * @param[out] indices Container of property indices
+ * @note The container will be cleared
+ */
+ void GetChildPropertyIndices( Property::IndexContainer& indices ) const;
+
+ /**
* @brief Given a property index, retrieve the property name associated with it.
*
* @SINCE_1_0.0