X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fcontrols%2Fcontrol%2Fcontrol-debug.cpp;h=9a9c08fe171898e79df66b6bc439aa53f9940ad2;hp=bcb69ac7db3c428a51cfa683d7e6a64f4469bc24;hb=f2039d47f9bed8104575da80a2ecf0bb6e37ff8d;hpb=f3e45e41c5f16ccc2538b283897ed6efb07e4ea9;ds=sidebyside diff --git a/dali-toolkit/internal/controls/control/control-debug.cpp b/dali-toolkit/internal/controls/control/control-debug.cpp index bcb69ac..9a9c08f 100644 --- a/dali-toolkit/internal/controls/control/control-debug.cpp +++ b/dali-toolkit/internal/controls/control/control-debug.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018 Samsung Electronics Co., Ltd. + * Copyright (c) 2021 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. @@ -14,16 +14,16 @@ * limitations under the License. */ -#include -#include -#include -#include #include #include #include -#include +#include +#include +#include +#include #include #include +#include #if defined(DEBUG_ENABLED) @@ -33,11 +33,10 @@ namespace Toolkit { namespace Internal { - class JsonWriter { public: - JsonWriter( Property::Value& value ) + JsonWriter(Property::Value& value) : mValue(value) { } @@ -45,18 +44,18 @@ public: std::string ToString() { std::ostringstream stream; - ToStream( stream ); + ToStream(stream); return stream.str(); } - void ToStream( std::ostream& stream ) + void ToStream(std::ostream& stream) { - switch( mValue.GetType() ) + switch(mValue.GetType()) { case Dali::Property::BOOLEAN: { auto value = mValue.Get(); - stream << ((value)?"true":"false"); + stream << ((value) ? "true" : "false"); break; } case Dali::Property::FLOAT: @@ -91,9 +90,9 @@ public: { auto matrix = mValue.Get(); stream << "["; - for( int i=0; i<9; ++i ) + for(int i = 0; i < 9; ++i) { - if( i>0) + if(i > 0) stream << ","; stream << matrix.AsFloat()[i]; } @@ -104,9 +103,9 @@ public: { auto matrix = mValue.Get(); stream << "["; - for( int i=0; i<16; ++i ) + for(int i = 0; i < 16; ++i) { - if( i>0) + if(i > 0) stream << ","; stream << matrix.AsFloat()[i]; } @@ -135,13 +134,13 @@ public: { auto array = mValue.GetArray(); stream << "[ "; - if( array ) + if(array) { - for( Property::Array::SizeType i=0; iSize(); ++i) + for(Property::Array::SizeType i = 0; i < array->Size(); ++i) { - if( i>0) + if(i > 0) stream << ", "; - auto outValue = JsonWriter( array->GetElementAt(i) ); + auto outValue = JsonWriter(array->GetElementAt(i)); stream << outValue.ToString(); } } @@ -152,14 +151,14 @@ public: { auto map = mValue.GetMap(); stream << "{ "; - if( map ) + if(map) { - for( Property::Map::SizeType i=0; iCount(); ++i) + for(Property::Map::SizeType i = 0; i < map->Count(); ++i) { - if( i>0) + if(i > 0) stream << ", "; - auto key = map->GetKeyAt( i ); - auto outValue = JsonWriter( map->GetValue(i) ); + auto key = map->GetKeyAt(i); + auto outValue = JsonWriter(map->GetValue(i)); stream << '\"' << key << "\":"; stream << outValue.ToString(); } @@ -183,32 +182,33 @@ public: Property::Value& mValue; }; -static std::ostream& operator<<( std::ostream& o, JsonWriter& value ) +static std::ostream& operator<<(std::ostream& o, JsonWriter& value) { value.ToStream(o); return o; } - -std::ostream& operator<<( std::ostream& o, const RegisteredVisual& registeredVisual ) +std::ostream& operator<<(std::ostream& o, const RegisteredVisual& registeredVisual) { - o << "{\n" << "\"index\":" << registeredVisual.index << ",\n"; - o << "\"enabled\":" << (registeredVisual.enabled?"true":"false") << ",\n"; - o << "\"pending\":" << (registeredVisual.pending?"true":"false") << ",\n"; + o << "{\n" + << "\"index\":" << registeredVisual.index << ",\n"; + o << "\"enabled\":" << (registeredVisual.enabled ? "true" : "false") << ",\n"; + o << "\"pending\":" << (registeredVisual.pending ? "true" : "false") << ",\n"; Property::Map map; - registeredVisual.visual.CreatePropertyMap( map ); + registeredVisual.visual.CreatePropertyMap(map); o << "\"visual\": {\n\"name\":\"" << registeredVisual.visual.GetName() << "\",\n"; - o << map << "}\n" << "\n}\n"; + o << map << "}\n" + << "\n}\n"; return o; } -std::ostream& operator<<( std::ostream& o, const RegisteredVisualContainer& visualContainer ) +std::ostream& operator<<(std::ostream& o, const RegisteredVisualContainer& visualContainer) { - o<<"[\n"; + o << "[\n"; - bool first=true; - for( auto&& elem : visualContainer ) + bool first = true; + for(auto&& elem : visualContainer) { if(!first) { @@ -216,132 +216,132 @@ std::ostream& operator<<( std::ostream& o, const RegisteredVisualContainer& visu } first = false; - o<<*elem<<"\n"; + o << *elem << "\n"; } - o<<"]\n"; + o << "]\n"; return o; } -std::ostream& DumpProperty( std::ostream& o, Property::Index index, Handle handle ) +std::ostream& DumpProperty(std::ostream& o, Property::Index index, Handle handle) { - auto propertyValue = handle.GetProperty( index ); + auto propertyValue = handle.GetProperty(index); auto jsonPropertyValue = JsonWriter(propertyValue); o << "{\n"; o << "\"index\":" << index << ",\n"; - o << "\"name\":\"" << handle.GetPropertyName( index ) << "\",\n"; + o << "\"name\":\"" << handle.GetPropertyName(index) << "\",\n"; o << "\"value\":" << jsonPropertyValue << "\n"; o << "}"; return o; } - -std::ostream& DumpPropertiesWithPredicate( std::ostream& o, Dali::Handle handle, - Property::IndexContainer& indices, std::function predicate) +std::ostream& DumpPropertiesWithPredicate(std::ostream& o, Dali::Handle handle, Property::IndexContainer& indices, std::function predicate) { bool first = true; - for( auto index : indices ) + for(auto index : indices) { - if( predicate( index ) ) + if(predicate(index)) { - if( !first ) + if(!first) { o << ","; } o << std::endl; first = false; - DumpProperty( o, index, handle ); + DumpProperty(o, index, handle); } } return o; } -std::ostream& DumpProperties( std::ostream& o, Handle handle ) +std::ostream& DumpProperties(std::ostream& o, Handle handle) { Property::IndexContainer indices; - handle.GetPropertyIndices( indices ); + handle.GetPropertyIndices(indices); - auto childPropertiesP = [](int index) -> bool - { - return CHILD_PROPERTY_REGISTRATION_START_INDEX <= index && index <= CHILD_PROPERTY_REGISTRATION_MAX_INDEX; - }; - auto propertiesP = [](int index) -> bool - { - return !(CHILD_PROPERTY_REGISTRATION_START_INDEX <= index && index <= CHILD_PROPERTY_REGISTRATION_MAX_INDEX); - }; + auto childPropertiesP = [](int index) -> bool { + return CHILD_PROPERTY_REGISTRATION_START_INDEX <= index && index <= CHILD_PROPERTY_REGISTRATION_MAX_INDEX; + }; + auto propertiesP = [](int index) -> bool { + return !(CHILD_PROPERTY_REGISTRATION_START_INDEX <= index && index <= CHILD_PROPERTY_REGISTRATION_MAX_INDEX); + }; - o << "\"childProperties\":[\n" ; - DumpPropertiesWithPredicate( o, handle, indices, childPropertiesP ); - o << std::endl << "]," << std::endl; + o << "\"childProperties\":[\n"; + DumpPropertiesWithPredicate(o, handle, indices, childPropertiesP); + o << std::endl + << "]," << std::endl; - o << "\"Properties\":[\n" ; - DumpPropertiesWithPredicate( o, handle, indices, propertiesP ); - o << std::endl << "]" << std::endl; + o << "\"Properties\":[\n"; + DumpPropertiesWithPredicate(o, handle, indices, propertiesP); + o << std::endl + << "]" << std::endl; return o; } -std::string DumpControl( const Internal::Control& control ) +std::string DumpControl(const Internal::Control& control) { - auto& controlData = Internal::Control::Impl::Get( control ); + auto& controlData = Internal::Control::Impl::Get(control); std::ostringstream oss; oss << "{\n "; - const std::string& name = control.Self().GetProperty< std::string >( Dali::Actor::Property::NAME ); - if( ! name.empty() ) + const std::string& name = control.Self().GetProperty(Dali::Actor::Property::NAME); + if(!name.empty()) { oss << "\"name\":\"" << name << "\",\n"; } - oss << "\"id\":\"" << control.Self().GetProperty< int >( Actor::Property::ID ) << "\",\n"; - oss << "\"registeredVisuals\":\n" << controlData.mVisuals << ",\n"; - oss << "\"removeVisuals\":\n" << controlData.mRemoveVisuals << ",\n"; + oss << "\"id\":\"" << control.Self().GetProperty(Actor::Property::ID) << "\",\n"; + oss << "\"registeredVisuals\":\n" + << controlData.mVisuals << ",\n"; + oss << "\"removeVisuals\":\n" + << controlData.mRemoveVisuals << ",\n"; oss << "\"rendererCount\":" << control.Self().GetRendererCount() << ",\n"; oss << "\"properties\":\n{\n"; - DumpProperties( oss, control.Self() ) << "}\n"; + DumpProperties(oss, control.Self()) << "}\n"; oss << "}\n"; return oss.str(); } -std::string DumpActor( Actor actor ) +std::string DumpActor(Actor actor) { std::ostringstream oss; oss << "{\n "; - const std::string& name = actor.GetProperty< std::string >( Dali::Actor::Property::NAME ); - if( ! name.empty() ) + const std::string& name = actor.GetProperty(Dali::Actor::Property::NAME); + if(!name.empty()) { oss << "\"name\":\"" << name << "\",\n"; } - oss << "\"id\":\"" << actor.GetProperty< int >( Actor::Property::ID ) << "\",\n"; + oss << "\"id\":\"" << actor.GetProperty(Actor::Property::ID) << "\",\n"; oss << "\"rendererCount\":" << actor.GetRendererCount() << ",\n"; oss << "\"properties\":\n{\n"; - Toolkit::Internal::DumpProperties( oss, actor ) << "}\n"; + Toolkit::Internal::DumpProperties(oss, actor) << "}\n"; oss << "}\n"; return oss.str(); } -void DumpControlHierarchy( std::ostream& o, Actor actor ) +void DumpControlHierarchy(std::ostream& o, Actor actor) { - auto control = Toolkit::Control::DownCast( actor ); + auto control = Toolkit::Control::DownCast(actor); o << "{\n"; - if( control ) + if(control) { - o << "\"Control\":" << DumpControl( Toolkit::Internal::GetImplementation( control ) ); + o << "\"Control\":" << DumpControl(Toolkit::Internal::GetImplementation(control)); } else { - o << "\"Actor\":" << DumpActor( actor ); + o << "\"Actor\":" << DumpActor(actor); } o << ",\n\"children\":[\n"; - bool first=true; - for( auto count=actor.GetChildCount(), i=0u; i