Merge "Clean up the code to build successfully on macOS" into devel/master
[platform/core/uifw/dali-core.git] / dali / public-api / object / 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 // CLASS HEADER
19 #include <dali/public-api/object/handle.h>
20
21 // INTERNAL INCLUDES
22 #include <dali/integration-api/debug.h>
23 #include <dali/internal/event/animation/constraint-impl.h>
24 #include <dali/internal/event/common/object-impl.h>
25 #include <dali/public-api/animation/constraint.h>
26 #include <dali/public-api/object/property-conditions.h>
27 #include <dali/public-api/object/property-notification.h>
28
29 namespace Dali
30 {
31 Handle::Handle(Dali::Internal::Object* handle)
32 : BaseHandle(handle)
33 {
34 }
35
36 Handle::Handle() = default;
37
38 Handle Handle::New()
39 {
40   return Handle(Internal::Object::New().Get());
41 }
42
43 Handle::~Handle() = default;
44
45 Handle::Handle(const Handle& handle) = default;
46
47 Handle& Handle::operator=(const Handle& rhs) = default;
48
49 Handle::Handle(Handle&& rhs) = default;
50
51 Handle& Handle::operator=(Handle&& rhs) = default;
52
53 Handle Handle::DownCast(BaseHandle handle)
54 {
55   return Handle(dynamic_cast<Dali::Internal::Object*>(handle.GetObjectPtr()));
56 }
57
58 bool Handle::Supports(Capability capability) const
59 {
60   return GetImplementation(*this).Supports(capability);
61 }
62
63 uint32_t Handle::GetPropertyCount() const
64 {
65   return GetImplementation(*this).GetPropertyCount();
66 }
67
68 std::string Handle::GetPropertyName(Property::Index index) const
69 {
70   return GetImplementation(*this).GetPropertyName(index);
71 }
72
73 Property::Index Handle::GetPropertyIndex(Property::Key key) const
74 {
75   return GetImplementation(*this).GetPropertyIndex(key);
76 }
77
78 bool Handle::IsPropertyWritable(Property::Index index) const
79 {
80   return GetImplementation(*this).IsPropertyWritable(index);
81 }
82
83 bool Handle::IsPropertyAnimatable(Property::Index index) const
84 {
85   return GetImplementation(*this).IsPropertyAnimatable(index);
86 }
87
88 bool Handle::IsPropertyAConstraintInput(Property::Index index) const
89 {
90   return GetImplementation(*this).IsPropertyAConstraintInput(index);
91 }
92
93 Property::Type Handle::GetPropertyType(Property::Index index) const
94 {
95   return GetImplementation(*this).GetPropertyType(index);
96 }
97
98 void Handle::SetProperty(Property::Index index, Property::Value propertyValue)
99 {
100   GetImplementation(*this).SetProperty(index, std::move(propertyValue));
101 }
102
103 Property::Index Handle::RegisterProperty(std::string name, Property::Value propertyValue)
104 {
105   return GetImplementation(*this).RegisterProperty(std::move(name), std::move(propertyValue));
106 }
107
108 Property::Index Handle::RegisterProperty(Property::Index key, std::string name, Property::Value propertyValue)
109 {
110   return GetImplementation(*this).RegisterProperty(std::move(name), key, std::move(propertyValue));
111 }
112
113 Property::Index Handle::RegisterProperty(std::string name, Property::Value propertyValue, Property::AccessMode accessMode)
114 {
115   return GetImplementation(*this).RegisterProperty(std::move(name), std::move(propertyValue), accessMode);
116 }
117
118 Property::Value Handle::GetProperty(Property::Index index) const
119 {
120   return GetImplementation(*this).GetProperty(index);
121 }
122
123 Property::Value Handle::GetCurrentProperty(Property::Index index) const
124 {
125   return GetImplementation(*this).GetCurrentProperty(index);
126 }
127
128 void Handle::SetProperties(const Property::Map& properties)
129 {
130   GetImplementation(*this).SetProperties(properties);
131 }
132
133 void Handle::GetProperties(Property::Map& properties)
134 {
135   GetImplementation(*this).GetProperties(properties);
136 }
137
138 void Handle::GetPropertyIndices(Property::IndexContainer& indices) const
139 {
140   GetImplementation(*this).GetPropertyIndices(indices);
141 }
142
143 bool Handle::DoesCustomPropertyExist(Property::Index index)
144 {
145   return GetImplementation(*this).DoesCustomPropertyExist(index);
146 }
147
148 Dali::PropertyNotification Handle::AddPropertyNotification(Property::Index          index,
149                                                            const PropertyCondition& condition)
150 {
151   return GetImplementation(*this).AddPropertyNotification(index, -1, condition);
152 }
153
154 Dali::PropertyNotification Handle::AddPropertyNotification(Property::Index          index,
155                                                            int                      componentIndex,
156                                                            const PropertyCondition& condition)
157 {
158   return GetImplementation(*this).AddPropertyNotification(index, componentIndex, condition);
159 }
160
161 void Handle::RemovePropertyNotification(Dali::PropertyNotification propertyNotification)
162 {
163   GetImplementation(*this).RemovePropertyNotification(propertyNotification);
164 }
165
166 void Handle::RemovePropertyNotifications()
167 {
168   GetImplementation(*this).RemovePropertyNotifications();
169 }
170
171 void Handle::RemoveConstraints()
172 {
173   GetImplementation(*this).RemoveConstraints();
174 }
175
176 void Handle::RemoveConstraints(uint32_t tag)
177 {
178   GetImplementation(*this).RemoveConstraints(tag);
179 }
180
181 IndirectValue Handle::operator[](Property::Index index)
182 {
183   // Will assert on access if handle is empty
184   return IndirectValue(*this, index);
185 }
186
187 IndirectValue Handle::operator[](const std::string& name)
188 {
189   // Will assert immediately when GetPropertyIndex is called if handle is empty
190   return IndirectValue(*this, GetPropertyIndex(name));
191 }
192
193 Handle::PropertySetSignalType& Handle::PropertySetSignal()
194 {
195   return GetImplementation(*this).PropertySetSignal();
196 }
197
198 namespace WeightObject
199 {
200 const Property::Index WEIGHT = PROPERTY_CUSTOM_START_INDEX;
201
202 Handle New()
203 {
204   Handle handle = Handle::New();
205
206   handle.RegisterProperty("weight", 0.0f);
207
208   return handle;
209 }
210
211 } // namespace WeightObject
212
213 } // namespace Dali