2 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
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
8 // http://floralicense.org/license/
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.
21 #include <dali/public-api/object/base-handle.h>
22 #include <dali/public-api/object/type-registry.h>
25 #include <dali/internal/event/common/object-impl.h>
26 #include <dali/integration-api/debug.h>
31 BaseHandle::BaseHandle(Dali::BaseObject* handle)
32 : mObjectHandle(handle)
36 BaseHandle::BaseHandle()
40 BaseHandle::~BaseHandle()
44 BaseHandle::BaseHandle(const BaseHandle& handle)
45 : mObjectHandle(handle.mObjectHandle)
49 BaseHandle& BaseHandle::operator=(const BaseHandle& rhs)
53 this->mObjectHandle = rhs.mObjectHandle;
59 BaseHandle& BaseHandle::operator=(BaseHandle::NullType* rhs)
61 DALI_ASSERT_ALWAYS( (rhs == NULL) && "Can only assign NULL pointer to handle");
66 bool BaseHandle::DoAction(const std::string& command, const std::vector<Property::Value>& attributes)
68 return GetImplementation(*this).DoAction( command, attributes );
71 const std::string& BaseHandle::GetTypeName() const
73 return GetImplementation(*this).GetTypeName();
76 BaseObject& BaseHandle::GetBaseObject()
78 DALI_ASSERT_ALWAYS( mObjectHandle.Get() && "BaseHandle is empty" );
80 return static_cast<BaseObject&>(*mObjectHandle);
83 const BaseObject& BaseHandle::GetBaseObject() const
85 DALI_ASSERT_ALWAYS(mObjectHandle.Get() && "BaseHandle is empty" );
87 return static_cast<const BaseObject&>(*mObjectHandle);
90 void BaseHandle::Reset()
95 BaseHandle::operator BaseHandle::BooleanType() const
97 return mObjectHandle ? &BaseHandle::ThisIsSaferThanReturningVoidStar : NULL;
100 bool BaseHandle::operator==(const BaseHandle& rhs) const
102 return this->mObjectHandle == rhs.mObjectHandle;
105 bool BaseHandle::operator!=(const BaseHandle& rhs) const
107 return this->mObjectHandle != rhs.mObjectHandle;
110 Dali::RefObject* BaseHandle::GetObjectPtr() const
112 return mObjectHandle.Get();
115 bool BaseHandle::DoConnectSignal( ConnectionTrackerInterface* connectionTracker, const std::string& signalName, FunctorDelegate* functor )
117 return GetImplementation(*this).DoConnectSignal( connectionTracker, signalName, functor );
120 bool operator<(const BaseHandle& lhs, const BaseHandle& rhs)
122 return lhs.GetObjectPtr() < rhs.GetObjectPtr();