Merge "Clean up the code to build successfully on macOS" into devel/master
[platform/core/uifw/dali-core.git] / dali / public-api / object / type-registry.cpp
index a5e4ec6..93e0d0e 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 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.
 // EXTERNAL INCLUDES
 
 // INTERNAL INCLUDES
-#include <dali/public-api/object/property-index-ranges.h>
 #include <dali/internal/event/common/type-registry-impl.h>
+#include <dali/internal/event/object/default-property-metadata.h>
+#include <dali/public-api/object/property-index-ranges.h>
 
 namespace Dali
 {
+TypeRegistry::TypeRegistry() = default;
 
-TypeRegistry::TypeRegistry()
-{
-}
+TypeRegistry::~TypeRegistry() = default;
+
+TypeRegistry::TypeRegistry(const TypeRegistry& copy) = default;
+
+TypeRegistry& TypeRegistry::operator=(const TypeRegistry& rhs) = default;
+
+TypeRegistry::TypeRegistry(TypeRegistry&& rhs) = default;
 
-TypeRegistry::~TypeRegistry()
+TypeRegistry& TypeRegistry::operator=(TypeRegistry&& rhs) = default;
+
+TypeRegistry TypeRegistry::Get()
 {
+  return TypeRegistry(Internal::TypeRegistry::Get());
 }
 
-TypeRegistry::TypeRegistry(const TypeRegistry& copy)
-: BaseHandle(copy)
+Dali::TypeInfo TypeRegistry::GetTypeInfo(const std::string& uniqueTypeName)
 {
+  return Dali::TypeInfo(GetImplementation(*this).GetTypeInfo(uniqueTypeName).Get());
 }
 
-TypeRegistry& TypeRegistry::operator=(const TypeRegistry& rhs)
+Dali::TypeInfo TypeRegistry::GetTypeInfo(const std::type_info& registerType)
 {
-  BaseHandle::operator=(rhs);
-  return *this;
+  return Dali::TypeInfo(GetImplementation(*this).GetTypeInfo(registerType).Get());
 }
 
-TypeRegistry TypeRegistry::Get()
+size_t TypeRegistry::GetTypeNameCount() const
 {
-  return TypeRegistry(Internal::TypeRegistry::Get());
+  return GetImplementation(*this).GetTypeNameCount();
 }
 
-Dali::TypeInfo TypeRegistry::GetTypeInfo( const std::string &uniqueTypeName )
+std::string TypeRegistry::GetTypeName(size_t index) const
 {
-  return GetImplementation(*this).GetTypeInfo( uniqueTypeName );
+  return GetImplementation(*this).GetTypeName(static_cast<uint32_t>(index));
 }
 
-Dali::TypeInfo TypeRegistry::GetTypeInfo( const std::type_info& registerType )
+TypeRegistry::TypeRegistry(Internal::TypeRegistry* internal)
+: BaseHandle(internal)
 {
-  return GetImplementation(*this).GetTypeInfo( registerType );
 }
 
-TypeRegistry::NameContainer TypeRegistry::GetTypeNames() const
+TypeRegistration::TypeRegistration(const std::type_info& registerType, const std::type_info& baseType, TypeInfo::CreateFunction f)
+: mReference(Internal::TypeRegistry::Get())
 {
-  return GetImplementation(*this).GetTypeNames();
+  Internal::TypeRegistry* impl = Internal::TypeRegistry::Get();
+
+  mName = impl->Register(registerType, baseType, f, false);
 }
 
-TypeRegistry::TypeRegistry(Internal::TypeRegistry* internal)
-: BaseHandle(internal)
+TypeRegistration::TypeRegistration(const std::type_info& registerType, const std::type_info& baseType, TypeInfo::CreateFunction f, bool callCreateOnInit)
+: mReference(Internal::TypeRegistry::Get())
 {
+  Internal::TypeRegistry* impl = Internal::TypeRegistry::Get();
+
+  mName = impl->Register(registerType, baseType, f, callCreateOnInit);
 }
 
-TypeRegistration::TypeRegistration( const std::type_info& registerType, const std::type_info& baseType,
-                                    TypeInfo::CreateFunction f )
-  : mReference(Internal::TypeRegistry::Get())
+TypeRegistration::TypeRegistration(const std::type_info& registerType, const std::type_info& baseType, TypeInfo::CreateFunction f, const DefaultPropertyMetadata& defaultProperties)
 {
-  Internal::TypeRegistry *impl = Internal::TypeRegistry::Get();
+  Internal::TypeRegistryimpl = Internal::TypeRegistry::Get();
 
-  if( impl->Register( registerType, baseType, f, false ) )
-  {
-    mName = impl->RegistrationName( registerType );
-  }
+  mName = impl->Register(registerType, baseType, f, false, defaultProperties.propertyTable, defaultProperties.propertyCount);
 }
 
-TypeRegistration::TypeRegistration( const std::type_info& registerType, const std::type_info& baseType,
-                                    TypeInfo::CreateFunction f, bool callCreateOnInit )
-  : mReference(Internal::TypeRegistry::Get())
+TypeRegistration::TypeRegistration(std::string name, const std::type_info& baseType, TypeInfo::CreateFunction f)
+: mReference(Internal::TypeRegistry::Get())
 {
-  Internal::TypeRegistry *impl = Internal::TypeRegistry::Get();
+  Internal::TypeRegistryimpl = Internal::TypeRegistry::Get();
 
-  if( impl->Register( registerType, baseType, f, callCreateOnInit ) )
-  {
-    mName = impl->RegistrationName( registerType );
-  }
+  mName = impl->Register(std::move(name), baseType, f, false);
 }
 
-TypeRegistration::TypeRegistration( const std::string& name, const std::type_info& baseType,
-                                    TypeInfo::CreateFunction f )
-  : mReference(Internal::TypeRegistry::Get())
+const std::string& TypeRegistration::RegisteredName() const
 {
-  Internal::TypeRegistry *impl = Internal::TypeRegistry::Get();
+  return mName;
+}
 
-  if( impl->Register( name, baseType, f, false ) )
-  {
-    mName = name;
-  }
+SignalConnectorType::SignalConnectorType(TypeRegistration& typeRegistration, std::string name, TypeInfo::SignalConnectorFunction func)
+{
+  Internal::TypeRegistry::Get()->RegisterSignal(typeRegistration, std::move(name), func);
 }
 
+TypeAction::TypeAction(TypeRegistration& registered, std::string name, TypeInfo::ActionFunction f)
+{
+  Internal::TypeRegistry::Get()->RegisterAction(registered, std::move(name), f);
+}
 
-const std::string TypeRegistration::RegisteredName() const
+PropertyRegistration::PropertyRegistration(TypeRegistration& registered, std::string name, Property::Index index, Property::Type type, TypeInfo::SetPropertyFunction setFunc, TypeInfo::GetPropertyFunction getFunc)
 {
-  return mName;
+  DALI_ASSERT_ALWAYS((index >= PROPERTY_REGISTRATION_START_INDEX) && (index <= PROPERTY_REGISTRATION_MAX_INDEX));
+
+  Internal::TypeRegistry::Get()->RegisterProperty(registered, std::move(name), index, type, setFunc, getFunc);
 }
 
-SignalConnectorType::SignalConnectorType( TypeRegistration& typeRegistration, const std::string& name, TypeInfo::SignalConnectorFunction func )
+AnimatablePropertyRegistration::AnimatablePropertyRegistration(TypeRegistration& registered, std::string name, Property::Index index, Property::Type type)
 {
-  Internal::TypeRegistry::Get()->RegisterSignal( typeRegistration, name, func );
+  DALI_ASSERT_ALWAYS((index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX) && (index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX));
+
+  Internal::TypeRegistry::Get()->RegisterAnimatableProperty(registered, std::move(name), index, type);
 }
 
-TypeAction::TypeAction( TypeRegistration &registered, const std::string &name, TypeInfo::ActionFunction f)
+AnimatablePropertyRegistration::AnimatablePropertyRegistration(TypeRegistration& registered, std::string name, Property::Index index, const Property::Value& value)
 {
-  Internal::TypeRegistry::Get()->RegisterAction( registered, name, f );
+  DALI_ASSERT_ALWAYS((index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX) && (index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX));
+
+  Internal::TypeRegistry::Get()->RegisterAnimatableProperty(registered, std::move(name), index, value);
 }
 
-PropertyRegistration::PropertyRegistration( TypeRegistration& registered, const std::string& name, Property::Index index, Property::Type type, TypeInfo::SetPropertyFunction setFunc, TypeInfo::GetPropertyFunction getFunc )
+AnimatablePropertyComponentRegistration::AnimatablePropertyComponentRegistration(TypeRegistration& registered, std::string name, Property::Index index, Property::Index baseIndex, uint32_t componentIndex)
 {
-  DALI_ASSERT_ALWAYS( ( index >= PROPERTY_REGISTRATION_START_INDEX ) && ( index <= PROPERTY_REGISTRATION_MAX_INDEX ) );
+  DALI_ASSERT_ALWAYS((index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX) && (index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX));
 
-  Internal::TypeRegistry::Get()->RegisterProperty( registered, name, index, type, setFunc, getFunc );
+  Internal::TypeRegistry::Get()->RegisterAnimatablePropertyComponent(registered, std::move(name), index, baseIndex, componentIndex);
 }
 
-AnimatablePropertyRegistration::AnimatablePropertyRegistration( TypeRegistration& registered, const std::string& name, Property::Index index, Property::Type type )
+ChildPropertyRegistration::ChildPropertyRegistration(TypeRegistration& registered, std::string name, Property::Index index, Property::Type type)
 {
-  DALI_ASSERT_ALWAYS( ( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX ) );
+  DALI_ASSERT_ALWAYS((index >= CHILD_PROPERTY_REGISTRATION_START_INDEX) && (index <= CHILD_PROPERTY_REGISTRATION_MAX_INDEX));
 
-  Internal::TypeRegistry::Get()->RegisterAnimatableProperty( registered, name, index, type );
+  Internal::TypeRegistry::Get()->RegisterChildProperty(registered, std::move(name), index, type);
 }
 
-AnimatablePropertyComponentRegistration::AnimatablePropertyComponentRegistration( TypeRegistration& registered, const std::string& name, Property::Index index, Property::Index baseIndex, unsigned int componentIndex)
+ChildPropertyRegistration::ChildPropertyRegistration(std::string registered, std::string name, Property::Index index, Property::Type type)
 {
-  DALI_ASSERT_ALWAYS( ( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX ) );
+  DALI_ASSERT_ALWAYS((index >= CHILD_PROPERTY_REGISTRATION_START_INDEX) && (index <= CHILD_PROPERTY_REGISTRATION_MAX_INDEX));
 
-  Internal::TypeRegistry::Get()->RegisterAnimatablePropertyComponent( registered, name, index, baseIndex, componentIndex );
+  Internal::TypeRegistry::Get()->RegisterChildProperty(std::move(registered), std::move(name), index, type);
 }
 
 } // namespace Dali