Event side structure.
[platform/core/uifw/dali-core.git] / dali / internal / event / common / object-impl-helper.h
1 #ifndef DALI_INTERNAL_OBJECT_IMPL_HELPER_H
2 #define DALI_INTERNAL_OBJECT_IMPL_HELPER_H
3
4 /*
5  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */
20
21 // INTERNAL INCLUDES
22 #include <dali/public-api/object/property.h> // Dali::Property
23 #include <dali/public-api/object/property-index-ranges.h> // DEFAULT_DERIVED_HANDLE_PROPERTY_START_INDEX
24 #include <dali/internal/event/common/property-helper.h> // Dali::Internal::PropertyDetails
25
26 namespace Dali
27 {
28 namespace Internal
29 {
30
31 class CustomProperty;
32 class PropertyInputImpl;
33
34 namespace SceneGraph
35 {
36
37 class PropertyBase;
38 class PropertyOwner;
39
40
41 } // namespace SceneGraph
42
43 /**
44  * Helper template class to be used by class that implement Object
45  *
46  * Example:
47  *<pre>
48  * typename ObjectImplHelper<DEFAULT_PROPERTY_COUNT, DEFAULT_PROPERTY_DETAILS> MyObjectImpl;
49  *
50  * MyObjectImpl::GetDefaultPropertyCount();
51  * </pre>
52  */
53
54 template<size_t DEFAULT_PROPERTY_COUNT>
55 struct ObjectImplHelper
56 {
57   const PropertyDetails* DEFAULT_PROPERTY_DETAILS;
58
59   unsigned int GetDefaultPropertyCount() const
60   {
61     return DEFAULT_PROPERTY_COUNT;
62   }
63
64   void GetDefaultPropertyIndices( Property::IndexContainer& indices ) const
65   {
66     indices.reserve( DEFAULT_PROPERTY_COUNT );
67
68     for ( int i = 0; i < DEFAULT_PROPERTY_COUNT; ++i )
69     {
70       indices.push_back( DEFAULT_DERIVED_HANDLE_PROPERTY_START_INDEX + i );
71     }
72   }
73
74   const char* GetDefaultPropertyName( Property::Index index ) const
75   {
76     const char* name = NULL;
77
78     if( index >= DEFAULT_DERIVED_HANDLE_PROPERTY_START_INDEX && index < DEFAULT_PROPERTY_COUNT )
79     {
80       name = DEFAULT_PROPERTY_DETAILS[index].name;
81     }
82
83     return name;
84   }
85
86   Property::Index GetDefaultPropertyIndex( const std::string& name ) const
87   {
88     Property::Index index = Property::INVALID_INDEX;
89
90     // Look for name in default properties
91     for( int i = 0; i < DEFAULT_PROPERTY_COUNT; ++i )
92     {
93       const Internal::PropertyDetails* property = &DEFAULT_PROPERTY_DETAILS[ i ];
94       if( 0 == strcmp( name.c_str(), property->name ) ) // dont want to convert rhs to string
95       {
96         index = i;
97         break;
98       }
99     }
100
101     return index;
102   }
103
104   bool IsDefaultPropertyWritable( Property::Index index ) const
105   {
106     bool isWritable = false;
107
108     if( index >= DEFAULT_DERIVED_HANDLE_PROPERTY_START_INDEX && index < DEFAULT_PROPERTY_COUNT )
109     {
110       isWritable = DEFAULT_PROPERTY_DETAILS[index].writable;
111     }
112
113     return isWritable;
114   }
115
116   bool IsDefaultPropertyAnimatable( Property::Index index ) const
117   {
118     bool isAnimatable = false;
119
120     if( index >= DEFAULT_DERIVED_HANDLE_PROPERTY_START_INDEX && index < DEFAULT_PROPERTY_COUNT )
121     {
122       isAnimatable =  DEFAULT_PROPERTY_DETAILS[index].animatable;
123     }
124
125     return isAnimatable;
126   }
127
128   bool IsDefaultPropertyAConstraintInput( Property::Index index ) const
129   {
130     bool isConstraintInput = false;
131
132     if( index >= DEFAULT_DERIVED_HANDLE_PROPERTY_START_INDEX && index < DEFAULT_PROPERTY_COUNT )
133     {
134       isConstraintInput = DEFAULT_PROPERTY_DETAILS[index].constraintInput;
135     }
136
137     return isConstraintInput;
138   }
139
140   Property::Type GetDefaultPropertyType( Property::Index index ) const
141   {
142     Property::Type type = Property::NONE;
143
144     if( index >= DEFAULT_DERIVED_HANDLE_PROPERTY_START_INDEX && index < DEFAULT_PROPERTY_COUNT )
145     {
146       type =  DEFAULT_PROPERTY_DETAILS[index].type;
147     }
148
149     return type;
150   }
151
152   void SetDefaultProperty( Property::Index index,
153                            const Property::Value& property ) const
154   {
155     // TODO: MESH_REWORK
156     DALI_ASSERT_ALWAYS( false && "TODO: MESH_REWORK" );
157   }
158
159   void SetSceneGraphProperty( Property::Index index,
160                               const CustomProperty& entry,
161                               const Property::Value& value ) const
162   {
163     // TODO: MESH_REWORK
164     DALI_ASSERT_ALWAYS( false && "TODO: MESH_REWORK" );
165   }
166
167   Property::Value GetDefaultProperty( Property::Index index ) const
168   {
169     Property::Value value;
170
171     // TODO: MESH_REWORK
172     DALI_ASSERT_ALWAYS( false && "TODO: MESH_REWORK" );
173
174     return value;
175   }
176
177   const SceneGraph::PropertyOwner* GetPropertyOwner() const
178   {
179     // TODO: MESH_REWORK
180     DALI_ASSERT_ALWAYS( false && "TODO: MESH_REWORK" );
181     return 0;
182   }
183
184   const SceneGraph::PropertyOwner* GetSceneObject() const
185   {
186     // TODO: MESH_REWORK
187     DALI_ASSERT_ALWAYS( false && "TODO: MESH_REWORK" );
188     return 0;
189   }
190
191   const SceneGraph::PropertyBase* GetSceneObjectAnimatableProperty( Property::Index index ) const
192   {
193     // TODO: MESH_REWORK
194     DALI_ASSERT_ALWAYS( false && "TODO: MESH_REWORK" );
195     return 0;
196   }
197
198   const PropertyInputImpl* GetSceneObjectInputProperty( Property::Index index ) const
199   {
200     // TODO: MESH_REWORK
201     DALI_ASSERT_ALWAYS( false && "TODO: MESH_REWORK" );
202     return 0;
203   }
204
205   int GetPropertyComponentIndex( Property::Index index ) const
206   {
207     // TODO: MESH_REWORK
208     DALI_ASSERT_ALWAYS( false && "TODO: MESH_REWORK" );
209     return 0;
210   }
211
212 };
213
214
215
216 } // namespace Internal
217
218 } // namespace Dali
219
220 #endif // DALI_INTERNAL_OBJECT_IMPL_HELPER_H
221