X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Finternal%2Fevent%2Fcommon%2Ftype-info-impl.h;h=37c43ed15fb95a196ac3ea2f07fc553f8e46199a;hb=33a8477946185463936981476e9772d40c37fd72;hp=6d90b75912714927eaecf714f43fa2204da0dd5b;hpb=a189f50d1870b7a2b26969cebbe06aba38dbbe97;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 6d90b75..37c43ed 100644 --- a/dali/internal/event/common/type-info-impl.h +++ b/dali/internal/event/common/type-info-impl.h @@ -1,8 +1,9 @@ #ifndef DALI_INTERNAL_TYPE_INFO_H #define DALI_INTERNAL_TYPE_INFO_H +#define USE_INDEXED_MAP_CONTAINER_AT_TYPE_INFO /// For safety. If some problem occured, just remove this define. /* - * Copyright (c) 2019 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 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. @@ -22,16 +23,21 @@ #include // INTERNAL INCLUDES +#ifdef USE_INDEXED_MAP_CONTAINER_AT_TYPE_INFO +#include +#include +#endif + +#include +#include +#include #include #include -#include #include -#include -#include +#include namespace Dali { - namespace Internal { class PropertyDetails; @@ -47,15 +53,13 @@ class TypeRegistry; 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, - const Dali::PropertyDetails* defaultProperties, Property::Index defaultPropertyCount ); + 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 @@ -63,7 +67,7 @@ public: * @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::CSharpTypeInfo::CreateFunction creator ); + TypeInfo(const std::string& name, const std::string& baseName, Dali::CSharpTypeInfo::CreateFunction creator); /** * Destructor @@ -98,7 +102,7 @@ public: /** * @copydoc Dali::TypeInfo::GetActionName */ - std::string GetActionName( uint32_t index ) const; + std::string GetActionName(uint32_t index) const; /** * @copydoc Dali::TypeInfo::GetSignalCount @@ -108,7 +112,7 @@ public: /** * @copydoc Dali::TypeInfo::GetSignalName */ - std::string GetSignalName( uint32_t index ) const; + std::string GetSignalName(uint32_t index) const; /** * @copydoc Dali::TypeInfo::GetPropertyCount @@ -119,13 +123,13 @@ public: * Adds the property indices to the container specified. * @param[in/out] indices The container where the property indices are added. */ - void GetPropertyIndices( Property::IndexContainer& indices ) const; + void GetPropertyIndices(Property::IndexContainer& indices) const; /** * @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; + std::string_view GetRegisteredPropertyName(Property::Index index) const; /** * Returns the property name for given index @@ -133,19 +137,19 @@ public: * @param index of the property * @return name or empty string */ - std::string GetPropertyName( Property::Index index ) const; + std::string_view GetPropertyName(Property::Index index) const; /* * Add an action function */ - void AddActionFunction( const std::string &actionName, Dali::TypeInfo::ActionFunction function ); + void AddActionFunction(std::string actionName, Dali::TypeInfo::ActionFunction function); /* * Add a function for connecting a signal. * @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::SignalConnectorFunction function ); + void AddConnectorFunction(std::string signalName, Dali::TypeInfo::SignalConnectorFunction function); /** * Adds an event-thread only property to the type. @@ -155,7 +159,7 @@ public: * @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 ); + void AddProperty(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. @@ -165,7 +169,7 @@ public: * @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); + void AddProperty(std::string name, Property::Index index, Property::Type type, Dali::CSharpTypeInfo::SetPropertyFunction setFunc, Dali::CSharpTypeInfo::GetPropertyFunction getFunc); /** * Adds an animatable property to the type. @@ -173,7 +177,7 @@ public: * @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 ); + void AddAnimatableProperty(std::string name, Property::Index index, Property::Type type); /** * Adds an animatable property with the given default value. @@ -181,7 +185,7 @@ public: * @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 ); + void AddAnimatableProperty(std::string name, Property::Index index, Property::Value defaultValue); /** * Adds a component of an animatable property to the type. @@ -191,7 +195,7 @@ public: * @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 ); + void AddAnimatablePropertyComponent(std::string name, Property::Index index, Property::Index baseIndex, uint32_t componentIndex); /** * Adds a child property to the type. @@ -199,7 +203,7 @@ public: * @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 ); + void AddChildProperty(std::string name, Property::Index index, Property::Type type); /** * Do an action on base object @@ -208,7 +212,7 @@ public: * @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 Property::Map &properties); + bool DoActionTo(BaseObject* object, const std::string& actionName, const Property::Map& properties); /** * Connects a callback function with the object's signals. @@ -219,87 +223,87 @@ public: * @return True if the signal was connected. * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor. */ - bool ConnectSignal( BaseObject* object, ConnectionTrackerInterface* connectionTracker, const std::string& signalName, FunctorDelegate* functor ); + bool ConnectSignal(BaseObject* object, ConnectionTrackerInterface* connectionTracker, const std::string& signalName, FunctorDelegate* functor); /** * Given a property name, retrieve the index. * @param[in] name The name of the property. * @return The index associated with that name. */ - Property::Index GetPropertyIndex( const std::string& name ) const; + Property::Index GetPropertyIndex(ConstString name) const; /** * 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; + 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; + 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; + bool IsPropertyWritable(Property::Index index) const; /** * @param[in] index The property index. * @return True, if animatable, false otherwise. */ - bool IsPropertyAnimatable( Property::Index index ) const; + 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; + 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. */ - Property::Type GetPropertyType( Property::Index index ) const; + 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; + Property::Index GetChildPropertyIndex(ConstString 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; + std::string_view 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; + 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; + 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; + Property::Value GetPropertyDefaultValue(Property::Index index) const; /** * Sets the value of a property at the index specified for the given object. @@ -307,7 +311,7 @@ public: * @param[in] index The property index. * @param[in] value The value to set. */ - void SetProperty( BaseObject *object, Property::Index index, const Property::Value& value ) const; + void SetProperty(BaseObject* object, Property::Index index, Property::Value value) const; /** * Sets the value of a property with the name specified for the given object. @@ -315,7 +319,7 @@ public: * @param[in] name The property name. * @param[in] value The value to set. */ - void SetProperty( BaseObject *object, const std::string& name, const Property::Value& value ) const; + void SetProperty(BaseObject* object, const std::string& name, Property::Value value) const; /** * Retrieves the value of a property at the index specified for the given object. @@ -323,7 +327,7 @@ public: * @param[in] index The property index. * @return The current value of the property. */ - Property::Value GetProperty( const BaseObject *object, Property::Index index ) const; + Property::Value GetProperty(const BaseObject* object, Property::Index index) const; /** * Retrieves the value of a property with the name specified for the given object. @@ -331,38 +335,36 @@ public: * @param[in] name The property name. * @return The current value of the property. */ - Property::Value GetProperty( const BaseObject *object, const std::string& name ) const; + Property::Value GetProperty(const BaseObject* object, const std::string& name) const; private: - struct RegisteredProperty { - 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, ConstString 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, Property::Index basePropertyIndex, int componentIndex ) - : type( propType ), - setFunc( set ), - getFunc( get ), - name( propName ), + RegisteredProperty(Property::Type propType, Dali::TypeInfo::SetPropertyFunction set, Dali::TypeInfo::GetPropertyFunction get, ConstString propName, Property::Index basePropertyIndex, int componentIndex) + : type(propType), + setFunc(set), + getFunc(get), + 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 ), + RegisteredProperty(Property::Type propType, Dali::CSharpTypeInfo::SetPropertyFunction set, Dali::CSharpTypeInfo::GetPropertyFunction get, ConstString propName, Property::Index basePropertyIndex, int componentIndex) + : type(propType), + cSharpSetFunc(set), + cSharpGetFunc(get), + name(propName), basePropertyIndex(basePropertyIndex), componentIndex(componentIndex) { @@ -371,56 +373,67 @@ private: Property::Type type = Property::NONE; union { - Dali::TypeInfo::SetPropertyFunction setFunc = nullptr; + 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::TypeInfo::GetPropertyFunction getFunc = nullptr; Dali::CSharpTypeInfo::GetPropertyFunction cSharpGetFunc; // only one field can be initialized but this will have same value anyways }; - std::string name; + ConstString name; Property::Index basePropertyIndex = Property::INVALID_INDEX; - int32_t componentIndex = Property::INVALID_COMPONENT_INDEX; + int32_t componentIndex = Property::INVALID_COMPONENT_INDEX; }; - using ConnectionPair = std::pair; - using ActionPair = std::pair; - using RegisteredPropertyPair = std::pair; - using PropertyDefaultValuePair = std::pair; - + using ActionPair = std::pair; + using ConnectionPair = std::pair; +#ifdef USE_INDEXED_MAP_CONTAINER_AT_TYPE_INFO + using RegisteredPropertyPair = std::pair; + using PropertyDefaultValuePair = std::pair; +#else + using RegisteredPropertyPair = std::pair; + using PropertyDefaultValuePair = std::pair; +#endif + +#ifdef USE_INDEXED_MAP_CONTAINER_AT_TYPE_INFO + using ActionContainer = Dali::Internal::IndexedConstStringMap; + using ConnectorContainer = Dali::Internal::IndexedConstStringMap; + using RegisteredPropertyContainer = Dali::Internal::IndexedIntegerMap; + using PropertyDefaultValueContainer = Dali::Internal::IndexedIntegerMap; +#else using ActionContainer = std::vector; using ConnectorContainer = std::vector; using RegisteredPropertyContainer = std::vector; using PropertyDefaultValueContainer = std::vector; +#endif /** * 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; + void AppendProperties(Dali::Property::IndexContainer& indices, + const TypeInfo::RegisteredPropertyContainer& registeredProperties) const; private: - - TypeRegistry& mTypeRegistry; + TypeRegistry& mTypeRegistry; mutable Internal::TypeInfo* mBaseType; // allow changing from const methods, initialised inside constructor - std::string mTypeName; - std::string mBaseTypeName; + std::string mTypeName; + std::string mBaseTypeName; union { - Dali::TypeInfo::CreateFunction mCreate = nullptr; + Dali::TypeInfo::CreateFunction mCreate = nullptr; Dali::CSharpTypeInfo::CreateFunction mCSharpCreate; // only one field can be initialized but this will have same value anyways }; - ActionContainer mActions; - ConnectorContainer mSignalConnectors; - RegisteredPropertyContainer mRegisteredProperties; - RegisteredPropertyContainer mRegisteredChildProperties; + ActionContainer mActions; + 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++) + 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