From 8c95d6be87506c28f7630bbbe20374043a4b6950 Mon Sep 17 00:00:00 2001 From: "Eunki, Hong" Date: Mon, 8 Jul 2024 10:30:30 +0900 Subject: [PATCH] Remove useless macro Since we use IndexedMap for a long time and it doesn't show any problem, let we remove this macro Change-Id: Ifa949d9b4a2b40238770d63b170d9dd462ff0f95 Signed-off-by: Eunki, Hong --- dali/internal/event/common/type-info-impl.cpp | 160 +------------------------- dali/internal/event/common/type-info-impl.h | 21 +--- 2 files changed, 4 insertions(+), 177 deletions(-) diff --git a/dali/internal/event/common/type-info-impl.cpp b/dali/internal/event/common/type-info-impl.cpp index 46d1b48..e5e90e7 100644 --- a/dali/internal/event/common/type-info-impl.cpp +++ b/dali/internal/event/common/type-info-impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Samsung Electronics Co., Ltd. + * Copyright (c) 2024 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. @@ -215,11 +215,7 @@ bool TypeInfo::DoActionTo(BaseObject* object, const std::string& actionName, con { bool done = false; -#ifdef USE_INDEXED_MAP_CONTAINER_AT_TYPE_INFO auto iter = mActions.Get(ConstString(actionName)); -#else - ActionContainer::iterator iter = find_if(mActions.begin(), mActions.end(), PairFinder(actionName)); -#endif if(iter != mActions.end()) { done = (iter->second)(object, actionName, properties); @@ -241,11 +237,7 @@ bool TypeInfo::ConnectSignal(BaseObject* object, ConnectionTrackerInterface* con { bool connected(false); -#ifdef USE_INDEXED_MAP_CONTAINER_AT_TYPE_INFO auto iter = mSignalConnectors.Get(ConstString(signalName)); -#else - ConnectorContainer::iterator iter = find_if(mSignalConnectors.begin(), mSignalConnectors.end(), PairFinder(signalName)); -#endif if(iter != mSignalConnectors.end()) { connected = (iter->second)(object, connectionTracker, signalName, functor); @@ -298,11 +290,7 @@ std::string TypeInfo::GetActionName(uint32_t index) const if(index < count) { -#ifdef USE_INDEXED_MAP_CONTAINER_AT_TYPE_INFO name = std::string(mActions.GetKeyByIndex(index).GetStringView()); -#else - name = mActions[index].first; -#endif } else { @@ -336,11 +324,7 @@ std::string TypeInfo::GetSignalName(uint32_t index) const if(index < count) { -#ifdef USE_INDEXED_MAP_CONTAINER_AT_TYPE_INFO name = std::string(mSignalConnectors.GetKeyByIndex(index).GetStringView()); -#else - name = mSignalConnectors[index].first; -#endif } else { @@ -405,11 +389,7 @@ void TypeInfo::AppendProperties(Dali::Property::IndexContainer& ind std::string_view TypeInfo::GetRegisteredPropertyName(Property::Index index) const { -#ifdef USE_INDEXED_MAP_CONTAINER_AT_TYPE_INFO const auto& iter = mRegisteredProperties.Get(static_cast(index)); -#else - RegisteredPropertyContainer::const_iterator iter = find_if(mRegisteredProperties.begin(), mRegisteredProperties.end(), PairFinder(index)); -#endif if(iter != mRegisteredProperties.end()) { return iter->second.name.GetStringView(); @@ -437,11 +417,7 @@ std::string_view TypeInfo::GetPropertyName(Property::Index index) const } else { -#ifdef USE_INDEXED_MAP_CONTAINER_AT_TYPE_INFO const auto& iter = mRegisteredProperties.Get(static_cast(index)); -#else - RegisteredPropertyContainer::const_iterator iter = find_if(mRegisteredProperties.begin(), mRegisteredProperties.end(), PairFinder(index)); -#endif if(iter != mRegisteredProperties.end()) { return iter->second.name.GetStringView(); @@ -468,23 +444,10 @@ void TypeInfo::AddActionFunction(std::string actionName, Dali::TypeInfo::ActionF } else { -#ifdef USE_INDEXED_MAP_CONTAINER_AT_TYPE_INFO if(!mActions.Register(ConstString(actionName), function)) { DALI_LOG_WARNING("Action already exists in TypeRegistry Type\n", actionName.c_str()); } -#else - ActionContainer::iterator iter = std::find_if(mActions.begin(), mActions.end(), PairFinder(actionName)); - - if(iter == mActions.end()) - { - mActions.push_back(ActionPair(std::move(actionName), function)); - } - else - { - DALI_LOG_WARNING("Action already exists in TypeRegistry Type\n", actionName.c_str()); - } -#endif } } @@ -496,23 +459,10 @@ void TypeInfo::AddConnectorFunction(std::string signalName, Dali::TypeInfo::Sign } else { -#ifdef USE_INDEXED_MAP_CONTAINER_AT_TYPE_INFO if(!mSignalConnectors.Register(ConstString(signalName), function)) { DALI_LOG_WARNING("Signal name already exists in TypeRegistry Type for signal connector function\n", signalName.c_str()); } -#else - ConnectorContainer::iterator iter = find_if(mSignalConnectors.begin(), mSignalConnectors.end(), PairFinder(signalName)); - - if(iter == mSignalConnectors.end()) - { - mSignalConnectors.push_back(ConnectionPair(std::move(signalName), function)); - } - else - { - DALI_LOG_WARNING("Signal name already exists in TypeRegistry Type for signal connector function\n", signalName.c_str()); - } -#endif } } @@ -526,22 +476,10 @@ void TypeInfo::AddProperty(std::string name, Property::Index index, Property::Ty } else { -#ifdef USE_INDEXED_MAP_CONTAINER_AT_TYPE_INFO if(!mRegisteredProperties.Register(static_cast(index), RegisteredProperty(type, setFunc, getFunc, ConstString(name), Property::INVALID_INDEX, Property::INVALID_COMPONENT_INDEX))) { DALI_ASSERT_ALWAYS(!"Property index already added to Type"); } -#else - RegisteredPropertyContainer::iterator iter = find_if(mRegisteredProperties.begin(), mRegisteredProperties.end(), PairFinder(index)); - if(iter == mRegisteredProperties.end()) - { - mRegisteredProperties.push_back(RegisteredPropertyPair(index, RegisteredProperty(type, setFunc, getFunc, ConstString(name), Property::INVALID_INDEX, Property::INVALID_COMPONENT_INDEX))); - } - else - { - DALI_ASSERT_ALWAYS(!"Property index already added to Type"); - } -#endif } } @@ -555,48 +493,23 @@ void TypeInfo::AddProperty(std::string name, Property::Index index, Property::Ty } else { -#ifdef USE_INDEXED_MAP_CONTAINER_AT_TYPE_INFO if(!mRegisteredProperties.Register(static_cast(index), RegisteredProperty(type, setFunc, getFunc, ConstString(name), Property::INVALID_INDEX, Property::INVALID_COMPONENT_INDEX))) { DALI_ASSERT_ALWAYS(!"Property index already added to Type"); } -#else - RegisteredPropertyContainer::iterator iter = find_if(mRegisteredProperties.begin(), mRegisteredProperties.end(), PairFinder(index)); - if(iter == mRegisteredProperties.end()) - { - mRegisteredProperties.push_back(RegisteredPropertyPair(index, RegisteredProperty(type, setFunc, getFunc, ConstString(name), Property::INVALID_INDEX, Property::INVALID_COMPONENT_INDEX))); - } - else - { - DALI_ASSERT_ALWAYS(!"Property index already added to Type"); - } -#endif } } void TypeInfo::AddAnimatableProperty(std::string name, Property::Index index, Property::Type type) { -#ifdef USE_INDEXED_MAP_CONTAINER_AT_TYPE_INFO if(!mRegisteredProperties.Register(static_cast(index), RegisteredProperty(type, ConstString(name), Property::INVALID_INDEX, Property::INVALID_COMPONENT_INDEX))) { DALI_ASSERT_ALWAYS(!"Property index already added to Type"); } -#else - RegisteredPropertyContainer::iterator iter = find_if(mRegisteredProperties.begin(), mRegisteredProperties.end(), PairFinder(index)); - if(iter == mRegisteredProperties.end()) - { - mRegisteredProperties.push_back(RegisteredPropertyPair(index, RegisteredProperty(type, ConstString(name), Property::INVALID_INDEX, Property::INVALID_COMPONENT_INDEX))); - } - else - { - DALI_ASSERT_ALWAYS(!"Property index already added to Type"); - } -#endif } void TypeInfo::AddAnimatableProperty(std::string name, Property::Index index, Property::Value defaultValue) { -#ifdef USE_INDEXED_MAP_CONTAINER_AT_TYPE_INFO if(!mRegisteredProperties.Register(static_cast(index), RegisteredProperty(defaultValue.GetType(), ConstString(name), Property::INVALID_INDEX, Property::INVALID_COMPONENT_INDEX))) { DALI_ASSERT_ALWAYS(!"Property index already added to Type"); @@ -605,18 +518,6 @@ void TypeInfo::AddAnimatableProperty(std::string name, Property::Index index, Pr { mPropertyDefaultValues.Register(static_cast(index), std::move(defaultValue)); } -#else - RegisteredPropertyContainer::iterator iter = find_if(mRegisteredProperties.begin(), mRegisteredProperties.end(), PairFinder(index)); - if(iter == mRegisteredProperties.end()) - { - mRegisteredProperties.push_back(RegisteredPropertyPair(index, RegisteredProperty(defaultValue.GetType(), ConstString(name), Property::INVALID_INDEX, Property::INVALID_COMPONENT_INDEX))); - mPropertyDefaultValues.push_back(PropertyDefaultValuePair(index, std::move(defaultValue))); - } - else - { - DALI_ASSERT_ALWAYS(!"Property index already added to Type"); - } -#endif } void TypeInfo::AddAnimatablePropertyComponent(std::string name, Property::Index index, Property::Index baseIndex, uint32_t componentIndex) @@ -626,7 +527,6 @@ void TypeInfo::AddAnimatablePropertyComponent(std::string name, Property::Index bool success = false; -#ifdef USE_INDEXED_MAP_CONTAINER_AT_TYPE_INFO if(mRegisteredProperties.Get(static_cast(index)) == mRegisteredProperties.end()) { const auto& iter = find_if(mRegisteredProperties.begin(), mRegisteredProperties.end(), PropertyComponentFinder(baseIndex, componentIndex)); @@ -637,35 +537,13 @@ void TypeInfo::AddAnimatablePropertyComponent(std::string name, Property::Index success = true; } } -#else - RegisteredPropertyContainer::iterator iter = find_if(mRegisteredProperties.begin(), mRegisteredProperties.end(), PairFinder(index)); - if(iter == mRegisteredProperties.end()) - { - iter = find_if(mRegisteredProperties.begin(), mRegisteredProperties.end(), PropertyComponentFinder(baseIndex, componentIndex)); - - if(iter == mRegisteredProperties.end()) - { - mRegisteredProperties.push_back(RegisteredPropertyPair(index, RegisteredProperty(type, ConstString(name), baseIndex, componentIndex))); - success = true; - } - } -#endif DALI_ASSERT_ALWAYS(success && "Property component already registered"); } void TypeInfo::AddChildProperty(std::string name, Property::Index index, Property::Type type) { -#ifdef USE_INDEXED_MAP_CONTAINER_AT_TYPE_INFO if(!mRegisteredChildProperties.Register(static_cast(index), RegisteredProperty(type, ConstString(name), Property::INVALID_INDEX, Property::INVALID_COMPONENT_INDEX))) -#else - RegisteredPropertyContainer::iterator iter = find_if(mRegisteredChildProperties.begin(), mRegisteredChildProperties.end(), PairFinder(index)); - if(iter == mRegisteredChildProperties.end()) - { - mRegisteredChildProperties.push_back(RegisteredPropertyPair(index, RegisteredProperty(type, ConstString(name), Property::INVALID_INDEX, Property::INVALID_COMPONENT_INDEX))); - } - else -#endif { DALI_ASSERT_ALWAYS(!"Property index already added to Type"); } @@ -725,11 +603,7 @@ Property::Index TypeInfo::GetBasePropertyIndex(Property::Index index) const { Property::Index basePropertyIndex = Property::INVALID_INDEX; -#ifdef USE_INDEXED_MAP_CONTAINER_AT_TYPE_INFO const auto& iter = mRegisteredProperties.Get(static_cast(index)); -#else - RegisteredPropertyContainer::const_iterator iter = find_if(mRegisteredProperties.begin(), mRegisteredProperties.end(), PairFinder(index)); -#endif if(iter != mRegisteredProperties.end()) { basePropertyIndex = iter->second.basePropertyIndex; @@ -747,11 +621,7 @@ int32_t TypeInfo::GetComponentIndex(Property::Index index) const { int componentIndex = Property::INVALID_COMPONENT_INDEX; -#ifdef USE_INDEXED_MAP_CONTAINER_AT_TYPE_INFO const auto& iter = mRegisteredProperties.Get(static_cast(index)); -#else - RegisteredPropertyContainer::const_iterator iter = find_if(mRegisteredProperties.begin(), mRegisteredProperties.end(), PairFinder(index)); -#endif if(iter != mRegisteredProperties.end()) { componentIndex = iter->second.componentIndex; @@ -787,11 +657,7 @@ Property::Index TypeInfo::GetChildPropertyIndex(ConstString name) const std::string_view TypeInfo::GetChildPropertyName(Property::Index index) const { -#ifdef USE_INDEXED_MAP_CONTAINER_AT_TYPE_INFO const auto& iter = mRegisteredChildProperties.Get(static_cast(index)); -#else - RegisteredPropertyContainer::const_iterator iter = find_if(mRegisteredChildProperties.begin(), mRegisteredChildProperties.end(), PairFinder(index)); -#endif if(iter != mRegisteredChildProperties.end()) { return iter->second.name.GetStringView(); @@ -812,11 +678,7 @@ Property::Type TypeInfo::GetChildPropertyType(Property::Index index) const { Property::Type type(Property::NONE); -#ifdef USE_INDEXED_MAP_CONTAINER_AT_TYPE_INFO const auto& iter = mRegisteredChildProperties.Get(static_cast(index)); -#else - RegisteredPropertyContainer::const_iterator iter = find_if(mRegisteredChildProperties.begin(), mRegisteredChildProperties.end(), PairFinder(index)); -#endif if(iter != mRegisteredChildProperties.end()) { type = iter->second.type; @@ -851,11 +713,7 @@ bool TypeInfo::IsPropertyWritable(Property::Index index) const } else { -#ifdef USE_INDEXED_MAP_CONTAINER_AT_TYPE_INFO const auto& iter = mRegisteredProperties.Get(static_cast(index)); -#else - RegisteredPropertyContainer::const_iterator iter = find_if(mRegisteredProperties.begin(), mRegisteredProperties.end(), PairFinder(index)); -#endif if(iter != mRegisteredProperties.end()) { writable = iter->second.setFunc ? true : false; @@ -970,11 +828,7 @@ Property::Type TypeInfo::GetPropertyType(Property::Index index) const } else { -#ifdef USE_INDEXED_MAP_CONTAINER_AT_TYPE_INFO const auto& iter = mRegisteredProperties.Get(static_cast(index)); -#else - RegisteredPropertyContainer::const_iterator iter = find_if(mRegisteredProperties.begin(), mRegisteredProperties.end(), PairFinder(index)); -#endif if(iter != mRegisteredProperties.end()) { if(iter->second.componentIndex == Property::INVALID_COMPONENT_INDEX) @@ -1009,11 +863,7 @@ Property::Type TypeInfo::GetPropertyType(Property::Index index) const Property::Value TypeInfo::GetPropertyDefaultValue(Property::Index index) const { -#ifdef USE_INDEXED_MAP_CONTAINER_AT_TYPE_INFO const auto& iter = mPropertyDefaultValues.Get(static_cast(index)); -#else - PropertyDefaultValueContainer::const_iterator iter = find_if(mPropertyDefaultValues.begin(), mPropertyDefaultValues.end(), PairFinder(index)); -#endif if(iter != mPropertyDefaultValues.end()) { return iter->second; @@ -1029,11 +879,7 @@ Property::Value TypeInfo::GetPropertyDefaultValue(Property::Index index) const void TypeInfo::SetProperty(BaseObject* object, Property::Index index, Property::Value value) const { -#ifdef USE_INDEXED_MAP_CONTAINER_AT_TYPE_INFO const auto& iter = mRegisteredProperties.Get(static_cast(index)); -#else - RegisteredPropertyContainer::const_iterator iter = find_if(mRegisteredProperties.begin(), mRegisteredProperties.end(), PairFinder(index)); -#endif if(iter != mRegisteredProperties.end()) { if(iter->second.setFunc) @@ -1093,11 +939,7 @@ void TypeInfo::SetProperty(BaseObject* object, const std::string& name, Property Property::Value TypeInfo::GetProperty(const BaseObject* object, Property::Index index) const { -#ifdef USE_INDEXED_MAP_CONTAINER_AT_TYPE_INFO const auto& iter = mRegisteredProperties.Get(static_cast(index)); -#else - RegisteredPropertyContainer::const_iterator iter = find_if(mRegisteredProperties.begin(), mRegisteredProperties.end(), PairFinder(index)); -#endif if(iter != mRegisteredProperties.end()) { if(mCSharpType) // using csharp property get which returns a pointer to a Property::Value diff --git a/dali/internal/event/common/type-info-impl.h b/dali/internal/event/common/type-info-impl.h index 37c43ed..ad0de51 100644 --- a/dali/internal/event/common/type-info-impl.h +++ b/dali/internal/event/common/type-info-impl.h @@ -1,9 +1,8 @@ #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) 2022 Samsung Electronics Co., Ltd. + * Copyright (c) 2024 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. @@ -23,10 +22,8 @@ #include // INTERNAL INCLUDES -#ifdef USE_INDEXED_MAP_CONTAINER_AT_TYPE_INFO #include #include -#endif #include #include @@ -386,27 +383,15 @@ private: int32_t componentIndex = Property::INVALID_COMPONENT_INDEX; }; - using ActionPair = std::pair; - using ConnectionPair = std::pair; -#ifdef USE_INDEXED_MAP_CONTAINER_AT_TYPE_INFO + using ActionPair = std::pair; + using ConnectionPair = std::pair; 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. -- 2.7.4