Revert "License conversion from Flora to Apache 2.0"
[platform/core/uifw/dali-core.git] / dali / public-api / object / base-object.cpp
1 //
2 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
3 //
4 // Licensed under the Flora License, Version 1.0 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 //     http://floralicense.org/license/
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an AS IS BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16
17 // CLASS HEADER
18 #include <dali/public-api/object/base-object.h>
19
20 // INTERNAL INCLUDES
21 #include <dali/public-api/object/type-registry.h>
22 #include <dali/integration-api/debug.h>
23 #include <dali/internal/event/common/object-registry-impl.h>
24 #include <dali/internal/event/common/stage-impl.h>
25 #include <dali/internal/event/common/type-registry-impl.h>
26
27 using namespace std;
28
29 namespace Dali
30 {
31
32 BaseObject::BaseObject()
33 {
34 }
35
36 BaseObject::~BaseObject()
37 {
38 }
39
40 void BaseObject::RegisterObject()
41 {
42   if( Internal::Stage::IsInstalled() )
43   {
44     Internal::Stage::GetCurrent()->GetObjectRegistry().RegisterObject( this );
45   }
46 }
47
48 void BaseObject::UnregisterObject()
49 {
50   // Guard to allow handle destruction after Core has been destroyed
51   if( Internal::Stage::IsInstalled() )
52   {
53     Internal::Stage::GetCurrent()->GetObjectRegistry().UnregisterObject( this );
54   }
55 }
56
57 bool BaseObject::DoAction(const std::string& actionName, const std::vector<Property::Value>& attributes)
58 {
59   Dali::Internal::TypeRegistry* registry = Dali::Internal::TypeRegistry::Get();
60
61   if( registry )
62   {
63     return registry->DoActionTo(this, actionName, attributes);
64   }
65
66   return false;
67 }
68
69 const std::string& BaseObject::GetTypeName() const
70 {
71   Dali::Internal::TypeRegistry* registry = Dali::Internal::TypeRegistry::Get();
72
73   if( registry )
74   {
75     Dali::TypeInfo typeInfo = registry->GetTypeInfo(this);
76     if( typeInfo )
77     {
78       return typeInfo.GetName();
79     }
80   }
81
82   // We should not reach here
83   static const std::string INVALID_NAME;
84   DALI_LOG_ERROR( "TypeName Not Found\n" );
85   return INVALID_NAME;
86 }
87
88 bool BaseObject::DoConnectSignal( ConnectionTrackerInterface* connectionTracker, const std::string& signalName, FunctorDelegate* functor )
89 {
90   Dali::Internal::TypeRegistry* registry = Dali::Internal::TypeRegistry::Get();
91
92   if( registry )
93   {
94     return registry->ConnectSignal( this, connectionTracker, signalName, functor );
95   }
96
97   return false;
98 }
99
100 } // namespace Dali
101