Making DALi public API typesafe using guaranteed types; uint8_t, uint32_t
[platform/core/uifw/dali-core.git] / dali / public-api / object / handle.cpp
1 /*
2  * Copyright (c) 2018 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/public-api/animation/constraint.h>
23 #include <dali/public-api/object/property-conditions.h>
24 #include <dali/public-api/object/property-notification.h>
25 #include <dali/internal/event/animation/constraint-impl.h>
26 #include <dali/internal/event/common/object-impl.h>
27 #include <dali/internal/event/object/custom-object-internal.h>
28 #include <dali/integration-api/debug.h>
29
30 namespace Dali
31 {
32
33 Handle::Handle( Dali::Internal::Object* handle )
34 : BaseHandle(handle)
35 {
36 }
37
38
39 Handle::Handle()
40 {
41 }
42
43 Handle Handle::New()
44 {
45   return Handle( Internal::CustomObject::New() );
46 }
47
48 Handle::~Handle()
49 {
50 }
51
52 Handle::Handle( const Handle& handle )
53 : BaseHandle( handle )
54 {
55 }
56
57 Handle& Handle::operator=( const Handle& rhs )
58 {
59   if( this != &rhs )
60   {
61     BaseHandle::operator=(rhs);
62   }
63
64   return *this;
65 }
66
67 Handle Handle::DownCast( BaseHandle handle )
68 {
69   return Handle( dynamic_cast<Dali::Internal::Object*>(handle.GetObjectPtr()) );
70 }
71
72
73 bool Handle::Supports( Capability capability ) const
74 {
75   return GetImplementation(*this).Supports( capability );
76 }
77
78 uint32_t Handle::GetPropertyCount() const
79 {
80   return GetImplementation(*this).GetPropertyCount();
81 }
82
83 std::string Handle::GetPropertyName( Property::Index index ) const
84 {
85   return GetImplementation(*this).GetPropertyName( index );
86 }
87
88 Property::Index Handle::GetPropertyIndex( const std::string& name ) const
89 {
90   return GetImplementation(*this).GetPropertyIndex( name );
91 }
92
93 bool Handle::IsPropertyWritable( Property::Index index ) const
94 {
95   return GetImplementation(*this).IsPropertyWritable( index );
96 }
97
98 bool Handle::IsPropertyAnimatable( Property::Index index ) const
99 {
100   return GetImplementation(*this).IsPropertyAnimatable( index );
101 }
102
103 bool Handle::IsPropertyAConstraintInput( Property::Index index ) const
104 {
105   return GetImplementation(*this).IsPropertyAConstraintInput( index );
106 }
107
108 Property::Type Handle::GetPropertyType( Property::Index index ) const
109 {
110   return GetImplementation(*this).GetPropertyType( index );
111 }
112
113 void Handle::SetProperty( Property::Index index, const Property::Value& propertyValue )
114 {
115   GetImplementation(*this).SetProperty( index, propertyValue );
116 }
117
118 Property::Index Handle::RegisterProperty( const std::string& name, const Property::Value& propertyValue )
119 {
120   return GetImplementation(*this).RegisterProperty( name, propertyValue );
121 }
122
123 Property::Index Handle::RegisterProperty( const std::string& name, const Property::Value& propertyValue, Property::AccessMode accessMode )
124 {
125   return GetImplementation(*this).RegisterProperty( name, propertyValue, accessMode );
126 }
127
128 Property::Value Handle::GetProperty( Property::Index index ) const
129 {
130   return GetImplementation(*this).GetProperty( index );
131 }
132
133 Property::Value Handle::GetCurrentProperty( Property::Index index ) const
134 {
135   return GetImplementation( *this ).GetCurrentProperty( index );
136 }
137
138 void Handle::GetPropertyIndices( Property::IndexContainer& indices ) const
139 {
140   GetImplementation(*this).GetPropertyIndices( indices );
141 }
142
143 Dali::PropertyNotification Handle::AddPropertyNotification( Property::Index index,
144                                                             const PropertyCondition& condition )
145 {
146   return GetImplementation(*this).AddPropertyNotification( index, -1, condition );
147 }
148
149 Dali::PropertyNotification Handle::AddPropertyNotification( Property::Index index,
150                                                             int componentIndex,
151                                                             const PropertyCondition& condition )
152 {
153   return GetImplementation(*this).AddPropertyNotification( index, componentIndex, condition );
154 }
155
156 void Handle::RemovePropertyNotification( Dali::PropertyNotification propertyNotification )
157 {
158   GetImplementation(*this).RemovePropertyNotification( propertyNotification );
159 }
160
161 void Handle::RemovePropertyNotifications()
162 {
163   GetImplementation(*this).RemovePropertyNotifications();
164 }
165
166 void Handle::RemoveConstraints()
167 {
168   GetImplementation(*this).RemoveConstraints();
169 }
170
171 void Handle::RemoveConstraints( uint32_t tag )
172 {
173   GetImplementation(*this).RemoveConstraints( tag );
174 }
175
176 namespace WeightObject
177 {
178
179 const Property::Index WEIGHT = PROPERTY_CUSTOM_START_INDEX;
180
181 Handle New()
182 {
183   Handle handle = Handle::New();
184
185   handle.RegisterProperty( "weight", 0.0f );
186
187   return handle;
188 }
189
190 } // namespace WeightObject
191
192 } // namespace Dali