X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Finternal%2Fevent%2Fcommon%2Ftype-registry-impl.h;h=8f72dd0c1ff86cc83668cbbfc90e73d93d30b4da;hb=aee2350a06fac17860817a0e84ff97a4553dbbaa;hp=5423349b311f688e5153ab29eea25df87248f3c7;hpb=079e6fb6efe6e14445395a56af5df9238642b589;p=platform%2Fcore%2Fuifw%2Fdali-core.git diff --git a/dali/internal/event/common/type-registry-impl.h b/dali/internal/event/common/type-registry-impl.h index 5423349..8f72dd0 100644 --- a/dali/internal/event/common/type-registry-impl.h +++ b/dali/internal/event/common/type-registry-impl.h @@ -2,7 +2,7 @@ #define __DALI_INTERNAL_TYPE_REGISTRY_H__ /* - * Copyright (c) 2015 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. @@ -19,11 +19,12 @@ */ // INTERNAL INCLUDES -#include +#include #include #include #include #include +#include namespace Dali { @@ -31,8 +32,7 @@ namespace Dali namespace Internal { -//////////////////////////////////////////////////////////////////////////////// -class TypeRegistry; +class PropertyDetails; /* * @copydoc Dali::TypeRegistry @@ -40,54 +40,84 @@ class TypeRegistry; class TypeRegistry : public Dali::BaseObject { public: + + // using intrusive pointer instead of handles internally as they are considerably cheaper + using TypeInfoPointer = IntrusivePtr; + /** * Get the TypeRegistry */ static TypeRegistry *Get(); - /* + /** * @copydoc Dali::TypeRegistry::GetTypeInfo */ - Dali::TypeInfo GetTypeInfo( const std::string &uniqueTypeName ); + TypeInfoPointer GetTypeInfo( const std::string &uniqueTypeName ); - /* + /** * @copydoc Dali::TypeRegistry::GetTypeInfo */ - Dali::TypeInfo GetTypeInfo( const std::type_info& registerType ); + TypeInfoPointer GetTypeInfo( const std::type_info& registerType ); - /* + /** * @copydoc Dali::TypeRegistry::GetTypeNameCount */ size_t GetTypeNameCount() const; - /* + /** * @copydoc Dali::TypeRegistry::GetTypeName */ std::string GetTypeName(size_t index) const; - /* - * Register a creation function under a unique name. + /** + * Register a type + * * @param [in] theTypeInfo Type info for the type to be registered * @param [in] baseTypeInfo Type info for its base class * @param [in] createInstance Instance creation function - * @param [in] callCreateOnInit If true call createInstance on dali initialisation - * @return true if the name could be registered. + * @param [in] callCreateOnInit If true call createInstance on DALi initialisation + * @return the name of the registered type. */ - bool Register( const std::type_info& theTypeInfo, const std::type_info& baseTypeInfo, - Dali::TypeInfo::CreateFunction createInstance, bool callCreateOnInit ); + std::string Register( const std::type_info& theTypeInfo, const std::type_info& baseTypeInfo, + Dali::TypeInfo::CreateFunction createInstance, bool callCreateOnInit ); - /* - * Register a creation function under a unique name. - * @param [in] name The name type to be registered (must be unique) + /** + * Register a type + * + * @param [in] theTypeInfo Type info for the type to be registered * @param [in] baseTypeInfo Type info for its base class * @param [in] createInstance Instance creation function - * @param [in] callCreateOnInit If true call createInstance on dali initialisation - * @return true if the name could be registered. + * @param [in] callCreateOnInit If true call createInstance on DALi initialisation + * @param [in] defaultProperties the table of default property metadata + * @param [in] defaultPropertyCount count of default properties + * @return the name of the registered type. */ - bool Register( const std::string& name, const std::type_info& baseTypeInfo, - Dali::TypeInfo::CreateFunction createInstance, bool callCreateOnInit ); + std::string Register( const std::type_info& theTypeInfo, const std::type_info& baseTypeInfo, + Dali::TypeInfo::CreateFunction createInstance, bool callCreateOnInit, + const Dali::PropertyDetails* defaultProperties, Property::Index defaultPropertyCount ); - /* + /** + * Register a type + * + * @param [in] theTypeInfo Type info for the type to be registered + * @param [in] baseTypeInfo Type info for its base class + * @param [in] createInstance Instance creation function + * @param [in] callCreateOnInit If true call createInstance on DALi initialisation + * @param [in] defaultProperties the table of default property metadata + * @param [in] defaultPropertyCount count of default properties + * @return the name of the registered type. + */ + std::string Register( const std::string& name, const std::type_info& baseTypeInfo, + Dali::TypeInfo::CreateFunction createInstance, bool callCreateOnInit, + const Dali::PropertyDetails* defaultProperties = nullptr, Property::Index defaultPropertyCount = 0 ); + + /** + * @copydoc CSharpTypeRegistry::TypeRegistration( const std::string&, const std::type_info&, TypeInfo::CreateFunction ); + */ + void Register( const std::string& name, const std::type_info& baseTypeInfo, + Dali::CSharpTypeInfo::CreateFunction createInstance ); + + /** * Register a signal connector function to a type * @param [in] typeRegistration TypeRegistration object used to register the type * @param [in] name Signal name @@ -95,14 +125,14 @@ public: */ void RegisterSignal( TypeRegistration& typeRegistration, const std::string& name, Dali::TypeInfo::SignalConnectorFunction func ); - /* + /** * Register an action function to a type * @param [in] registered TypeRegistration object used to register the type * @param [in] name Action name * @param [in] f Action function * @return true if registered */ - bool RegisterAction( TypeRegistration ®istered, const std::string &name, Dali::TypeInfo::ActionFunction f); + bool RegisterAction( TypeRegistration& registered, const std::string& name, Dali::TypeInfo::ActionFunction f ); /** * Register an event-thread only property with a type @@ -117,6 +147,19 @@ public: bool RegisterProperty( TypeRegistration& registered, const std::string& name, Property::Index index, Property::Type type, Dali::TypeInfo::SetPropertyFunction setFunc, Dali::TypeInfo::GetPropertyFunction getFunc ); /** + * Register an event-thread only property with a type (used by C# Custom controls) + * @param [in] objectName name of the object used to register the type + * @param [in] name Property name + * @param [in] index Property index + * @param [in] type Property type + * @param [in] setFunc The function to set the property (Can be NULL). + * @param [in] getFunc The function to get the value of a property. + * @return true if registered + */ + bool RegisterProperty( const std::string& objectName, const std::string& name, Property::Index index, Property::Type type, Dali::CSharpTypeInfo::SetPropertyFunction setFunc, Dali::CSharpTypeInfo::GetPropertyFunction getFunc ); + + + /** * Register a scene graph only property with a type * @param [in] registered TypeRegistration object used to register the type * @param [in] name Property name @@ -127,6 +170,16 @@ public: bool RegisterAnimatableProperty( TypeRegistration& registered, const std::string& name, Property::Index index, Property::Type type ); /** + * Register a scene graph only property with a default value + * @param [in] registered TypeRegistration object used to register the type + * @param [in] name Property name + * @param [in] index Property index + * @param [in] value Property default value + * @return true if registered + */ + bool RegisterAnimatableProperty( TypeRegistration& registered, const std::string& name, Property::Index index, const Property::Value& defaultValue ); + + /** * Register a component of a scene graph only property that supports components (i.e. Vector2, Vector3 and Vector4) * @param [in] registered TypeRegistration object used to register the type * @param [in] name Component name @@ -137,7 +190,27 @@ public: */ bool RegisterAnimatablePropertyComponent( TypeRegistration& registered, const std::string& name, Property::Index index, Property::Index baseIndex, unsigned int componentIndex ); - /* + /** + * Register a event-thread only property with a type and a default value + * @param [in] registeredType Name of a registered type on which to register the child property. + * @param [in] name Property name + * @param [in] index Property index + * @param [in] type Property type + * @return true if registered + */ + bool RegisterChildProperty( const std::string& registeredType, const std::string& name, Property::Index index, Property::Type type ); + + /** + * Register a event-thread only property with a type and a default value + * @param [in] registered TypeRegistration object used to register the type + * @param [in] name Property name + * @param [in] index Property index + * @param [in] type Property type + * @return true if registered + */ + bool RegisterChildProperty( TypeRegistration& registered, const std::string& name, Property::Index index, Property::Type type ); + + /** * @copydoc Dali::Internal::TypeInfo::DoActionTo * Walks all base types until it finds a doer. */ @@ -148,14 +221,14 @@ public: */ bool ConnectSignal( BaseObject* object, ConnectionTrackerInterface* connectionTracker, const std::string& signalName, FunctorDelegate* functor ); - /* + /** * Return the type info for a given BaseObject pointer * @param [in] pBaseObject Pointer to a BaseObject * @return TypeInfo for the BaseObject. */ - Dali::TypeInfo GetTypeInfo(const Dali::BaseObject * const pBaseObject); + TypeInfoPointer GetTypeInfo(const Dali::BaseObject * const pBaseObject); - /* + /** * Calls any type creation functions that have been flagged as initialization functions */ void CallInitFunctions(void) const; @@ -171,13 +244,11 @@ public: private: /* - * Map from type name to TypeInfo + * Mapping from type name to TypeInfo */ - typedef std::map RegistryMap; - RegistryMap mRegistryLut; + std::vector< TypeInfoPointer > mRegistryLut; - typedef std::vector InitFunctions; - InitFunctions mInitFunctions; + std::vector< Dali::TypeInfo::CreateFunction > mInitFunctions; private: TypeRegistry();