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