X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Finternal%2Fevent%2Fcommon%2Ftype-info-impl.h;h=54cfe2248a254259a033e88b7ba3105a5689aa4c;hb=aee2350a06fac17860817a0e84ff97a4553dbbaa;hp=df42aa0bee54bfeb39c16ebdd6713b14c8304988;hpb=7f018a22b7063e1fc4cab37bc24aa1c11c718a21;p=platform%2Fcore%2Fuifw%2Fdali-core.git diff --git a/dali/internal/event/common/type-info-impl.h b/dali/internal/event/common/type-info-impl.h index df42aa0..54cfe22 100644 --- a/dali/internal/event/common/type-info-impl.h +++ b/dali/internal/event/common/type-info-impl.h @@ -2,7 +2,7 @@ #define __DALI_INTERNAL_TYPE_INFO_H__ /* - * Copyright (c) 2014 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. @@ -25,12 +25,17 @@ #include #include #include +#include +#include +#include namespace Dali { namespace Internal { +class PropertyDetails; +class TypeRegistry; /** * A TypeInfo class to support registered type creation, and introspection of available @@ -42,18 +47,28 @@ namespace Internal class TypeInfo : public BaseObject { public: + /** * Create TypeInfo * @param [name] the registered name * @param [baseName] the base type registered name * @param [creator] the creator function for this type */ - TypeInfo(const std::string &name, const std::string &baseName, Dali::TypeInfo::CreateFunction creator); + TypeInfo( const std::string& name, const std::string& baseName, Dali::TypeInfo::CreateFunction creator, + const Dali::PropertyDetails* defaultProperties, Property::Index defaultPropertyCount ); /** - * + * Create TypeInfo for a csharp object + * @param [name] the registered name + * @param [baseName] the base type registered name + * @param [creator] the creator function for this type */ - ~TypeInfo(); + TypeInfo( const std::string& name, const std::string& baseName, Dali::CSharpTypeInfo::CreateFunction creator ); + + /** + * Destructor + */ + virtual ~TypeInfo(); /** * @copydoc Dali::TypeInfo::GetName @@ -76,19 +91,29 @@ public: Dali::TypeInfo::CreateFunction GetCreator() const; /** - * @copydoc Dali::TypeInfo::GetActions + * @copydoc Dali::TypeInfo::GetActionCount + */ + size_t GetActionCount() const; + + /** + * @copydoc Dali::TypeInfo::GetActionName */ - void GetActions( Dali::TypeInfo::NameContainer& container ) const; + std::string GetActionName(size_t index) const; /** - * @copydoc Dali::TypeInfo::GetSignals + * @copydoc Dali::TypeInfo::GetSignalCount */ - void GetSignals( Dali::TypeInfo::NameContainer& container) const; + size_t GetSignalCount() const; /** - * @copydoc Dali::TypeInfo::GetProperties + * @copydoc Dali::TypeInfo::GetSignalName */ - void GetProperties( Dali::TypeInfo::NameContainer& container) const; + std::string GetSignalName(size_t index) const; + + /** + * @copydoc Dali::TypeInfo::GetPropertyCount + */ + uint32_t GetPropertyCount() const; /** * Adds the property indices to the container specified. @@ -98,8 +123,17 @@ public: /** * @copydoc Dali::TypeInfo::GetPropertyName() const + * this API exists to keep the old public API, which cannot be changed + */ + const std::string& GetRegisteredPropertyName( Property::Index index ) const; + + /** + * Returns the property name for given index + * + * @param index of the property + * @return name or empty string */ - const std::string& GetPropertyName( Property::Index index ) const; + std::string GetPropertyName( Property::Index index ) const; /* * Add an action function @@ -111,26 +145,70 @@ public: * @param[in] signalName The name of the signal. * @param[in] function The function used for connecting to the signal. */ - void AddConnectorFunction( const std::string& signalName, Dali::TypeInfo::SignalConnectorFunctionV2 function ); + void AddConnectorFunction( const std::string& signalName, Dali::TypeInfo::SignalConnectorFunction function ); /** * Adds an event-thread only property to the type. * @param[in] name The name of the property. * @param[in] index The index of the property. * @param[in] type The Property::Type. - * @param[in] setFunc The function to call to set the property (Can be NULL). + * @param[in] setFunc The function to call to set the property (Can be nullptr). * @param[in] getFunc The function to call to retrieve the value of the property. */ void AddProperty( const std::string& name, Property::Index index, Property::Type type, Dali::TypeInfo::SetPropertyFunction setFunc, Dali::TypeInfo::GetPropertyFunction getFunc ); /** + * Adds an event-thread only property to the type. + * @param[in] name The name of the property. + * @param[in] index The index of the property. + * @param[in] type The Property::Type. + * @param[in] setFunc The function to call to set the property (Can be nullptr). + * @param[in] getFunc The function to call to retrieve the value of the property. + */ + void AddProperty( const std::string& name, Property::Index index, Property::Type type, Dali::CSharpTypeInfo::SetPropertyFunction setFunc, Dali::CSharpTypeInfo::GetPropertyFunction getFunc); + + /** + * Adds an animatable property to the type. + * @param[in] name The name of the property. + * @param[in] index The index of the property + * @param[in] type The Property::Type. + */ + void AddAnimatableProperty( const std::string& name, Property::Index index, Property::Type type ); + + /** + * Adds an animatable property with the given default value. + * @param[in] name The name of the property. + * @param[in] index The index of the property + * @param[in] type The Property::Type. + */ + void AddAnimatableProperty( const std::string& name, Property::Index index, const Property::Value& defaultValue ); + + /** + * Adds a component of an animatable property to the type. + * The animatable property must have been type-registered and must be a Vector2, Vector3 or Vector4 type. + * @param[in] name The name of the component. + * @param[in] index The index of the property + * @param[in] baseIndex The index of the base animatable property + * @param[in] component The index The index of the component. + */ + void AddAnimatablePropertyComponent( const std::string& name, Property::Index index, Property::Index baseIndex, uint32_t componentIndex ); + + /** + * Adds a child property to the type. + * @param[in] name The name of the property. + * @param[in] index The index of the property + * @param[in] type The Property::Type. + */ + void AddChildProperty( const std::string& name, Property::Index index, Property::Type type ); + + /** * Do an action on base object * @param [in] object The base object to act upon * @param [in] actionName The name of the desired action * @param [in] properties The arguments of the action * @return bool If the action could be executed */ - bool DoActionTo(BaseObject *object, const std::string &actionName, const std::vector &properties); + bool DoActionTo(BaseObject *object, const std::string &actionName, const Property::Map &properties); /** * Connects a callback function with the object's signals. @@ -144,12 +222,6 @@ public: bool ConnectSignal( BaseObject* object, ConnectionTrackerInterface* connectionTracker, const std::string& signalName, FunctorDelegate* functor ); /** - * Retrieve the property count for this type. - * @return The total number of properties. - */ - unsigned int GetPropertyCount() const; - - /** * Given a property name, retrieve the index. * @param[in] name The name of the property. * @return The index associated with that name. @@ -157,13 +229,38 @@ public: Property::Index GetPropertyIndex( const std::string& name ) const; /** - * Checks if there is a setter for the property. If there is then it is writable. + * Given a property index, retrieve the index of its base property. + * @param[in] index The index of the property. + * @return The index of the base property associated with the given property index. + */ + Property::Index GetBasePropertyIndex( Property::Index index ) const; + + /** + * Given a property index, retrieve its component index. + * @param[in] index The index of the property. + * @return The component index associated with that property index. + */ + int32_t GetComponentIndex( Property::Index index ) const; + + /** * @param[in] index The property index. * @return True, if writable, false otherwise. */ bool IsPropertyWritable( Property::Index index ) const; /** + * @param[in] index The property index. + * @return True, if animatable, false otherwise. + */ + bool IsPropertyAnimatable( Property::Index index ) const; + + /** + * @param[in] index The property index. + * @return True, if a constraint input, false otherwise. + */ + bool IsPropertyAConstraintInput( Property::Index index ) const; + + /** * Retrieve the Property::Type of the property at the given index. * @param[in] index The property index. * @return The Property::Type at that index. @@ -171,6 +268,40 @@ public: Property::Type GetPropertyType( Property::Index index ) const; /** + * Given a child property name, retrieve the index. + * @param[in] name The name of the child property. + * @return The index associated with that name. + */ + Property::Index GetChildPropertyIndex( const std::string& name ) const; + + /** + * Retrieve the name of the child property at the given index. + * @param[in] index The property index. + * @return The name of the child property. + */ + const std::string& GetChildPropertyName( Property::Index index ) const; + + /** + * Retrieve the Property::Type of the child property at the given index. + * @param[in] index The property index. + * @return The Property::Type at that index. + */ + 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. + */ + Property::Value GetPropertyDefaultValue( Property::Index index ) const; + + /** * Sets the value of a property at the index specified for the given object. * @param[in] object The object whose property is to be set. * @param[in] index The property index. @@ -206,42 +337,90 @@ private: struct RegisteredProperty { - RegisteredProperty() - : type( Property::NONE ), - setFunc( NULL ), - getFunc( NULL ), - name() + RegisteredProperty( Property::Type propType, const std::string& propName, Property::Index basePropertyIndex, int32_t componentIndex ) + : type( propType ), + setFunc( nullptr ), + getFunc( nullptr ), + name( propName ), + basePropertyIndex(basePropertyIndex), + componentIndex(componentIndex) { } - RegisteredProperty( Property::Type propType, Dali::TypeInfo::SetPropertyFunction set, Dali::TypeInfo::GetPropertyFunction get, const std::string& propName ) + + RegisteredProperty( Property::Type propType, Dali::TypeInfo::SetPropertyFunction set, Dali::TypeInfo::GetPropertyFunction get, const std::string& propName, Property::Index basePropertyIndex, int componentIndex ) : type( propType ), setFunc( set ), getFunc( get ), - name( propName ) + name( propName ), + basePropertyIndex(basePropertyIndex), + componentIndex(componentIndex) + { + } + + RegisteredProperty( Property::Type propType, Dali::CSharpTypeInfo::SetPropertyFunction set, Dali::CSharpTypeInfo::GetPropertyFunction get, const std::string& propName, Property::Index basePropertyIndex, int componentIndex ) + : type( propType ), + cSharpSetFunc( set ), + cSharpGetFunc( get ), + name( propName ), + basePropertyIndex(basePropertyIndex), + componentIndex(componentIndex) { } - Property::Type type; - Dali::TypeInfo::SetPropertyFunction setFunc; - Dali::TypeInfo::GetPropertyFunction getFunc; + Property::Type type = Property::NONE; + union + { + Dali::TypeInfo::SetPropertyFunction setFunc = nullptr; + Dali::CSharpTypeInfo::SetPropertyFunction cSharpSetFunc; // only one field can be initialized but this will have same value anyways + }; + union + { + Dali::TypeInfo::GetPropertyFunction getFunc = nullptr; + Dali::CSharpTypeInfo::GetPropertyFunction cSharpGetFunc; // only one field can be initialized but this will have same value anyways + }; std::string name; + Property::Index basePropertyIndex = Property::INVALID_INDEX; + int32_t componentIndex = Property::INVALID_COMPONENT_INDEX; }; - typedef std::pair ConnectionPairV2; + typedef std::pair ConnectionPair; typedef std::pair ActionPair; typedef std::pair RegisteredPropertyPair; + typedef std::pair PropertyDefaultValuePair; typedef std::vector< ActionPair > ActionContainer; - typedef std::vector< ConnectionPairV2 > ConnectorContainerV2; + typedef std::vector< ConnectionPair > ConnectorContainer; 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: + TypeRegistry& mTypeRegistry; + mutable Internal::TypeInfo* mBaseType; // allow changing from const methods, initialised inside constructor std::string mTypeName; std::string mBaseTypeName; - Dali::TypeInfo::CreateFunction mCreate; + union + { + Dali::TypeInfo::CreateFunction mCreate = nullptr; + Dali::CSharpTypeInfo::CreateFunction mCSharpCreate; // only one field can be initialized but this will have same value anyways + }; ActionContainer mActions; - ConnectorContainerV2 mSignalConnectors; + ConnectorContainer mSignalConnectors; RegisteredPropertyContainer mRegisteredProperties; + RegisteredPropertyContainer mRegisteredChildProperties; + PropertyDefaultValueContainer mPropertyDefaultValues; + const Dali::PropertyDetails* mDefaultProperties = nullptr; + Property::Index mDefaultPropertyCount = 0; + bool mCSharpType = false; ///< Whether this type info is for a CSharp control (instead of C++) }; } // namespace Internal