X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Finternal%2Fevent%2Fcommon%2Ftype-registry-impl.cpp;h=c487ac3f8ad26c3dcc0f19f5a28a277b6c22dede;hb=18cda952771b365d009457555ba18b42bc9f55be;hp=58d4731536a1b051bb599ea4c6b26d3bbe3d5ef7;hpb=ce20e9f082e811130930d13c9e9edc1da4ce1013;p=platform%2Fcore%2Fuifw%2Fdali-core.git diff --git a/dali/internal/event/common/type-registry-impl.cpp b/dali/internal/event/common/type-registry-impl.cpp index 58d4731..c487ac3 100644 --- a/dali/internal/event/common/type-registry-impl.cpp +++ b/dali/internal/event/common/type-registry-impl.cpp @@ -1,33 +1,29 @@ -// -// Copyright (c) 2014 Samsung Electronics Co., Ltd. -// -// Licensed under the Flora License, Version 1.0 (the License); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://floralicense.org/license/ -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an AS IS BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// +/* + * Copyright (c) 2015 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ // CLASS HEADER #include -// EXTERNAL INCLUDES -#include -#include -#include -#include - // INTERNAL INCLUDES #include #include #include #include +#include #include @@ -38,51 +34,6 @@ namespace Debug::Filter* gLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_TYPE_REGISTRY"); #endif -std::vector SplitString(const std::string &s, char delim, std::vector &elems) -{ - std::stringstream ss(s); - std::string item; - while(std::getline(ss, item, delim)) - { - elems.push_back(item); - } - return elems; -} - -const int Demangle(const char* symbol, std::vector &resolved) -{ - int status = -4; - - char* res = abi::__cxa_demangle(symbol, NULL, NULL, &status); - - const char* const demangled_name = (status==0)?res:symbol; - - std::string sDemangled(demangled_name); - - free(res); - - SplitString(sDemangled, ':', resolved); - - return resolved.size(); -} - -const std::string DemangleShortName(const char *symbol) -{ - std::vector resolved; - - Demangle(symbol, resolved); - - if(resolved.size() > 0) - { - return resolved[ resolved.size() - 1 ]; - } - else - { - return std::string(symbol); - } - -} - } // namespace anon namespace Dali @@ -132,7 +83,7 @@ Dali::TypeInfo TypeRegistry::GetTypeInfo( const std::type_info& registerType ) { Dali::TypeInfo ret; - std::string typeName = DemangleShortName(registerType.name()); + std::string typeName = DemangleClassName(registerType.name()); RegistryMap::iterator iter = mRegistryLut.find(typeName); @@ -148,22 +99,31 @@ Dali::TypeInfo TypeRegistry::GetTypeInfo( const std::type_info& registerType ) return ret; } -Dali::TypeRegistry::NameContainer TypeRegistry::GetTypeNames() const +size_t TypeRegistry::GetTypeNameCount() const { - Dali::TypeRegistry::NameContainer ret; + return mRegistryLut.size(); +} + - for(RegistryMap::const_iterator iter = mRegistryLut.begin(); iter != mRegistryLut.end(); ++iter) +std::string TypeRegistry::GetTypeName(size_t index) const +{ + std::string name; + + if( index < mRegistryLut.size() ) { - ret.push_back(iter->first); + RegistryMap::const_iterator iter = mRegistryLut.begin(); + std::advance(iter, index); + name = iter->first; } - return ret; + return name; } + bool TypeRegistry::Register( const std::type_info& theTypeInfo, const std::type_info& baseTypeInfo, - Dali::TypeInfo::CreateFunction createInstance, bool callCreateOnInit ) + Dali::TypeInfo::CreateFunction createInstance, bool callCreateOnInit ) { - std::string uniqueTypeName = DemangleShortName(theTypeInfo.name()); + std::string uniqueTypeName = DemangleClassName(theTypeInfo.name()); return Register( uniqueTypeName, baseTypeInfo, createInstance, callCreateOnInit ); } @@ -173,7 +133,7 @@ bool TypeRegistry::Register( const std::string& uniqueTypeName, const std::type_ { bool ret = false; - std::string baseTypeName = DemangleShortName(baseTypeInfo.name()); + std::string baseTypeName = DemangleClassName(baseTypeInfo.name()); RegistryMap::iterator iter = mRegistryLut.find(uniqueTypeName); @@ -207,10 +167,10 @@ void TypeRegistry::CallInitFunctions(void) const std::string TypeRegistry::RegistrationName( const std::type_info& registerType ) { - return DemangleShortName( registerType.name() ); + return DemangleClassName( registerType.name() ); } -void TypeRegistry::RegisterSignal( TypeRegistration& typeRegistration, const std::string& name, Dali::TypeInfo::SignalConnectorFunctionV2 func ) +void TypeRegistry::RegisterSignal( TypeRegistration& typeRegistration, const std::string& name, Dali::TypeInfo::SignalConnectorFunction func ) { RegistryMap::iterator iter = mRegistryLut.find( typeRegistration.RegisteredName() ); @@ -240,7 +200,71 @@ bool TypeRegistry::RegisterAction( TypeRegistration ®istered, const std::stri } } -bool TypeRegistry::DoActionTo( BaseObject * const object, const std::string &actionName, const std::vector &properties) +bool TypeRegistry::RegisterProperty( TypeRegistration& registered, const std::string& name, Property::Index index, Property::Type type, Dali::TypeInfo::SetPropertyFunction setFunc, Dali::TypeInfo::GetPropertyFunction getFunc ) +{ + RegistryMap::iterator iter = mRegistryLut.find( registered.RegisteredName() ); + + if( iter != mRegistryLut.end() ) + { + DALI_ASSERT_DEBUG(iter->second); + + GetImplementation(iter->second).AddProperty( name, index, type, setFunc, getFunc ); + + return true; + } + + return false; +} + +bool TypeRegistry::RegisterAnimatableProperty( TypeRegistration& registered, const std::string& name, Property::Index index, Property::Type type ) +{ + RegistryMap::iterator iter = mRegistryLut.find( registered.RegisteredName() ); + + if( iter != mRegistryLut.end() ) + { + DALI_ASSERT_DEBUG(iter->second); + + GetImplementation(iter->second).AddAnimatableProperty( name, index, type ); + + return true; + } + + return false; +} + +bool TypeRegistry::RegisterAnimatableProperty( TypeRegistration& registered, const std::string& name, Property::Index index, const Property::Value& value ) +{ + RegistryMap::iterator iter = mRegistryLut.find( registered.RegisteredName() ); + + if( iter != mRegistryLut.end() ) + { + DALI_ASSERT_DEBUG(iter->second); + + GetImplementation(iter->second).AddAnimatableProperty( name, index, value ); + + return true; + } + + return false; +} + +bool TypeRegistry::RegisterAnimatablePropertyComponent( TypeRegistration& registered, const std::string& name, Property::Index index, Property::Index baseIndex, unsigned int componentIndex ) +{ + RegistryMap::iterator iter = mRegistryLut.find( registered.RegisteredName() ); + + if( iter != mRegistryLut.end() ) + { + DALI_ASSERT_DEBUG(iter->second); + + GetImplementation(iter->second).AddAnimatablePropertyComponent( name, index, baseIndex, componentIndex ); + + return true; + } + + return false; +} + +bool TypeRegistry::DoActionTo( BaseObject * const object, const std::string &actionName, const Property::Map &properties) { bool done = false; @@ -284,16 +308,17 @@ bool TypeRegistry::ConnectSignal( BaseObject* object, ConnectionTrackerInterface return connected; } -Dali::TypeInfo TypeRegistry::GetTypeInfo(Dali::BaseObject * const pBaseObject) +Dali::TypeInfo TypeRegistry::GetTypeInfo(const Dali::BaseObject * const pBaseObject) { Dali::TypeInfo type; // test for custom actor which has another indirection to get to the type hiearchy we're after - Dali::Internal::CustomActor * const pCustom = dynamic_cast(pBaseObject); + const Dali::Internal::CustomActor * const pCustom = dynamic_cast(pBaseObject); if(pCustom) { - type = GetTypeInfo( typeid( pCustom->GetImplementation() ) ); + const Dali::CustomActorImpl& custom = pCustom->GetImplementation(); + type = GetTypeInfo( typeid( custom ) ); } else {