removing use of using namespace std;
[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 Apache License, Version 2.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://www.apache.org/licenses/LICENSE-2.0
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
18 // CLASS HEADER
19 #include <dali/public-api/object/base-object.h>
20
21 // INTERNAL INCLUDES
22 #include <dali/public-api/object/type-registry.h>
23 #include <dali/integration-api/debug.h>
24 #include <dali/internal/event/common/object-registry-impl.h>
25 #include <dali/internal/event/common/stage-impl.h>
26 #include <dali/internal/event/common/type-registry-impl.h>
27
28 namespace Dali
29 {
30
31 BaseObject::BaseObject()
32 {
33 }
34
35 BaseObject::~BaseObject()
36 {
37 }
38
39 void BaseObject::RegisterObject()
40 {
41   if( Internal::Stage::IsInstalled() )
42   {
43     Internal::Stage::GetCurrent()->GetObjectRegistry().RegisterObject( this );
44   }
45 }
46
47 void BaseObject::UnregisterObject()
48 {
49   // Guard to allow handle destruction after Core has been destroyed
50   if( Internal::Stage::IsInstalled() )
51   {
52     Internal::Stage::GetCurrent()->GetObjectRegistry().UnregisterObject( this );
53   }
54 }
55
56 bool BaseObject::DoAction(const std::string& actionName, const std::vector<Property::Value>& attributes)
57 {
58   Dali::Internal::TypeRegistry* registry = Dali::Internal::TypeRegistry::Get();
59
60   if( registry )
61   {
62     return registry->DoActionTo(this, actionName, attributes);
63   }
64
65   return false;
66 }
67
68 const std::string& BaseObject::GetTypeName() const
69 {
70   Dali::Internal::TypeRegistry* registry = Dali::Internal::TypeRegistry::Get();
71
72   if( registry )
73   {
74     Dali::TypeInfo typeInfo = registry->GetTypeInfo(this);
75     if( typeInfo )
76     {
77       return typeInfo.GetName();
78     }
79   }
80
81   // Return an empty string if type-name not found.
82   DALI_LOG_WARNING( "TypeName Not Found\n" );
83   return String::EMPTY;
84 }
85
86 bool BaseObject::GetTypeInfo(Dali::TypeInfo& typeInfo) const
87 {
88   Dali::Internal::TypeRegistry* registry = Dali::Internal::TypeRegistry::Get();
89
90   Dali::TypeInfo info = registry->GetTypeInfo(this);
91   if(info)
92   {
93     typeInfo = info;
94     return true;
95   }
96   else
97   {
98     return false;
99   }
100 }
101
102 bool BaseObject::DoConnectSignal( ConnectionTrackerInterface* connectionTracker, const std::string& signalName, FunctorDelegate* functor )
103 {
104   Dali::Internal::TypeRegistry* registry = Dali::Internal::TypeRegistry::Get();
105
106   if( registry )
107   {
108     return registry->ConnectSignal( this, connectionTracker, signalName, functor );
109   }
110
111   return false;
112 }
113
114 } // namespace Dali
115