Revert "License conversion from Flora to Apache 2.0"
[platform/core/uifw/dali-core.git] / dali / public-api / object / base-handle.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 // EXTERNAL INCLUDES
18 #include <typeinfo>
19
20 // CLASS HEADER
21 #include <dali/public-api/object/base-handle.h>
22 #include <dali/public-api/object/type-registry.h>
23
24 // INTERNAL INCLUDES
25 #include <dali/internal/event/common/object-impl.h>
26 #include <dali/integration-api/debug.h>
27
28 namespace Dali
29 {
30
31 BaseHandle::BaseHandle(Dali::BaseObject* handle)
32 : mObjectHandle(handle)
33 {
34 }
35
36 BaseHandle::BaseHandle()
37 {
38 }
39
40 BaseHandle::~BaseHandle()
41 {
42 }
43
44 BaseHandle::BaseHandle(const BaseHandle& handle)
45   : mObjectHandle(handle.mObjectHandle)
46 {
47 }
48
49 BaseHandle& BaseHandle::operator=(const BaseHandle& rhs)
50 {
51   if( this != &rhs )
52   {
53     this->mObjectHandle = rhs.mObjectHandle;
54   }
55
56   return *this;
57 }
58
59 BaseHandle& BaseHandle::operator=(BaseHandle::NullType* rhs)
60 {
61   DALI_ASSERT_ALWAYS( (rhs == NULL) && "Can only assign NULL pointer to handle");
62   Reset();
63   return *this;
64 }
65
66 bool BaseHandle::DoAction(const std::string& command, const std::vector<Property::Value>& attributes)
67 {
68   return GetImplementation(*this).DoAction( command, attributes );
69 }
70
71 const std::string& BaseHandle::GetTypeName() const
72 {
73   return GetImplementation(*this).GetTypeName();
74 }
75
76 BaseObject& BaseHandle::GetBaseObject()
77 {
78   DALI_ASSERT_ALWAYS( mObjectHandle.Get() && "BaseHandle is empty" );
79
80   return static_cast<BaseObject&>(*mObjectHandle);
81 }
82
83 const BaseObject& BaseHandle::GetBaseObject() const
84 {
85   DALI_ASSERT_ALWAYS(mObjectHandle.Get() && "BaseHandle is empty" );
86
87   return static_cast<const BaseObject&>(*mObjectHandle);
88 }
89
90 void BaseHandle::Reset()
91 {
92   mObjectHandle = NULL;
93 }
94
95 BaseHandle::operator BaseHandle::BooleanType() const
96 {
97   return mObjectHandle ? &BaseHandle::ThisIsSaferThanReturningVoidStar : NULL;
98 }
99
100 bool BaseHandle::operator==(const BaseHandle& rhs) const
101 {
102   return this->mObjectHandle == rhs.mObjectHandle;
103 }
104
105 bool BaseHandle::operator!=(const BaseHandle& rhs) const
106 {
107   return this->mObjectHandle != rhs.mObjectHandle;
108 }
109
110 Dali::RefObject* BaseHandle::GetObjectPtr() const
111 {
112   return mObjectHandle.Get();
113 }
114
115 bool BaseHandle::DoConnectSignal( ConnectionTrackerInterface* connectionTracker, const std::string& signalName, FunctorDelegate* functor )
116 {
117   return GetImplementation(*this).DoConnectSignal( connectionTracker, signalName, functor );
118 }
119
120 bool operator<(const BaseHandle& lhs, const BaseHandle& rhs)
121 {
122   return lhs.GetObjectPtr() < rhs.GetObjectPtr();
123 }
124
125 } // namespace Dali