Merge "Clean up the code to build successfully on macOS" into devel/master
[platform/core/uifw/dali-core.git] / dali / public-api / object / base-handle.cpp
1 /*
2  * Copyright (c) 2020 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 // EXTERNAL INCLUDES
19 #include <typeinfo>
20
21 // CLASS HEADER
22 #include <dali/public-api/object/base-handle.h>
23 #include <dali/public-api/object/type-registry.h>
24
25 // INTERNAL INCLUDES
26 #include <dali/integration-api/debug.h>
27 #include <dali/internal/event/common/object-impl.h>
28
29 namespace Dali
30 {
31 BaseHandle::BaseHandle(Dali::BaseObject* handle)
32 : mObjectHandle(handle)
33 {
34 }
35
36 BaseHandle::BaseHandle() = default;
37
38 BaseHandle::~BaseHandle() = default;
39
40 BaseHandle::BaseHandle(const BaseHandle& handle) = default;
41
42 BaseHandle& BaseHandle::operator=(const BaseHandle& rhs) = default;
43
44 BaseHandle::BaseHandle(BaseHandle&& rhs) = default;
45
46 BaseHandle& BaseHandle::operator=(BaseHandle&& rhs) = default;
47
48 bool BaseHandle::DoAction(const std::string& command, const Property::Map& attributes)
49 {
50   return GetImplementation(*this).DoAction(command, attributes);
51 }
52
53 const std::string& BaseHandle::GetTypeName() const
54 {
55   return GetImplementation(*this).GetTypeName();
56 }
57
58 bool BaseHandle::GetTypeInfo(Dali::TypeInfo& typeInfo) const
59 {
60   return GetImplementation(*this).GetTypeInfo(typeInfo);
61 }
62
63 BaseObject& BaseHandle::GetBaseObject()
64 {
65   return static_cast<BaseObject&>(*mObjectHandle);
66 }
67
68 const BaseObject& BaseHandle::GetBaseObject() const
69 {
70   return static_cast<const BaseObject&>(*mObjectHandle);
71 }
72
73 void BaseHandle::Reset()
74 {
75   mObjectHandle = nullptr;
76 }
77
78 BaseHandle::operator BaseHandle::BooleanType() const
79 {
80   return mObjectHandle ? &BaseHandle::ThisIsSaferThanReturningVoidStar : nullptr;
81 }
82
83 bool BaseHandle::operator==(const BaseHandle& rhs) const
84 {
85   return this->mObjectHandle == rhs.mObjectHandle;
86 }
87
88 bool BaseHandle::operator!=(const BaseHandle& rhs) const
89 {
90   return this->mObjectHandle != rhs.mObjectHandle;
91 }
92
93 Dali::RefObject* BaseHandle::GetObjectPtr() const
94 {
95   return mObjectHandle.Get();
96 }
97
98 bool BaseHandle::DoConnectSignal(ConnectionTrackerInterface* connectionTracker, const std::string& signalName, FunctorDelegate* functor)
99 {
100   return GetImplementation(*this).DoConnectSignal(connectionTracker, signalName, functor);
101 }
102
103 } // namespace Dali