Merge branch 'tizen' of platform/core/uifw/dali-core into devel/new_mesh
[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 class PropertyMetadata;
31 class PropertyInputImpl;
32
33 namespace SceneGraph
34 {
35
36 class PropertyBase;
37 class PropertyOwner;
38
39
40 } // namespace SceneGraph
41
42 /**
43  * Helper template class to be used by class that implement Object
44  *
45  * Example:
46  *<pre>
47  * typename ObjectImplHelper<DEFAULT_PROPERTY_COUNT, DEFAULT_PROPERTY_DETAILS> MyObjectImpl;
48  *
49  * MyObjectImpl::GetDefaultPropertyCount();
50  * </pre>
51  */
52
53 template<int DEFAULT_PROPERTY_COUNT>
54 struct ObjectImplHelper
55 {
56   const PropertyDetails* DEFAULT_PROPERTY_DETAILS;
57
58   unsigned int GetDefaultPropertyCount() const
59   {
60     return DEFAULT_PROPERTY_COUNT;
61   }
62
63   void GetDefaultPropertyIndices( Property::IndexContainer& indices ) const
64   {
65     indices.reserve( DEFAULT_PROPERTY_COUNT );
66
67     for( unsigned int i = 0; i < DEFAULT_PROPERTY_COUNT; ++i )
68     {
69       indices.push_back( DEFAULT_OBJECT_PROPERTY_START_INDEX + i );
70     }
71   }
72
73   const char* GetDefaultPropertyName( Property::Index index ) const
74   {
75     const char* name = NULL;
76
77     if( index >= DEFAULT_OBJECT_PROPERTY_START_INDEX && index < DEFAULT_PROPERTY_COUNT )
78     {
79       name = DEFAULT_PROPERTY_DETAILS[index].name;
80     }
81
82     return name;
83   }
84
85   Property::Index GetDefaultPropertyIndex( const std::string& name ) const
86   {
87     Property::Index index = Property::INVALID_INDEX;
88
89     // Look for name in default properties
90     for( unsigned int i = 0; i < DEFAULT_PROPERTY_COUNT; ++i )
91     {
92       const Internal::PropertyDetails* property = &DEFAULT_PROPERTY_DETAILS[ i ];
93       if( 0 == strcmp( name.c_str(), property->name ) ) // dont want to convert rhs to string
94       {
95         index = i;
96         break;
97       }
98     }
99
100     return index;
101   }
102
103   bool IsDefaultPropertyWritable( Property::Index index ) const
104   {
105     bool isWritable = false;
106
107     if( index >= DEFAULT_OBJECT_PROPERTY_START_INDEX && index < DEFAULT_PROPERTY_COUNT )
108     {
109       isWritable = DEFAULT_PROPERTY_DETAILS[index].writable;
110     }
111
112     return isWritable;
113   }
114
115   bool IsDefaultPropertyAnimatable( Property::Index index ) const
116   {
117     bool isAnimatable = false;
118
119     if( index >= DEFAULT_OBJECT_PROPERTY_START_INDEX && index < DEFAULT_PROPERTY_COUNT )
120     {
121       isAnimatable =  DEFAULT_PROPERTY_DETAILS[index].animatable;
122     }
123
124     return isAnimatable;
125   }
126
127   bool IsDefaultPropertyAConstraintInput( Property::Index index ) const
128   {
129     bool isConstraintInput = false;
130
131     if( index >= DEFAULT_OBJECT_PROPERTY_START_INDEX && index < DEFAULT_PROPERTY_COUNT )
132     {
133       isConstraintInput = DEFAULT_PROPERTY_DETAILS[index].constraintInput;
134     }
135
136     return isConstraintInput;
137   }
138
139   Property::Type GetDefaultPropertyType( Property::Index index ) const
140   {
141     Property::Type type = Property::NONE;
142
143     if( index >= DEFAULT_OBJECT_PROPERTY_START_INDEX && index < DEFAULT_PROPERTY_COUNT )
144     {
145       type =  DEFAULT_PROPERTY_DETAILS[index].type;
146     }
147
148     return type;
149   }
150
151   void SetDefaultProperty( Property::Index index,
152                            const Property::Value& property ) const
153   {
154     // TODO: MESH_REWORK
155     DALI_ASSERT_ALWAYS( false && "TODO: MESH_REWORK" );
156   }
157
158   void SetSceneGraphProperty( Property::Index index,
159                               const PropertyMetadata& entry,
160                               const Property::Value& value ) const
161   {
162     // TODO: MESH_REWORK
163     DALI_ASSERT_ALWAYS( false && "TODO: MESH_REWORK" );
164   }
165
166   Property::Value GetDefaultProperty( Property::Index index ) const
167   {
168     Property::Value value;
169
170     // TODO: MESH_REWORK
171     DALI_ASSERT_ALWAYS( false && "TODO: MESH_REWORK" );
172
173     return value;
174   }
175
176   const SceneGraph::PropertyOwner* GetPropertyOwner() const
177   {
178     // TODO: MESH_REWORK
179     DALI_ASSERT_ALWAYS( false && "TODO: MESH_REWORK" );
180     return 0;
181   }
182
183   const SceneGraph::PropertyBase* GetSceneObjectAnimatableProperty( Property::Index index ) const
184   {
185     // TODO: MESH_REWORK
186     DALI_ASSERT_ALWAYS( false && "TODO: MESH_REWORK" );
187     return 0;
188   }
189
190   const PropertyInputImpl* GetSceneObjectInputProperty( Property::Index index ) const
191   {
192     // TODO: MESH_REWORK
193     DALI_ASSERT_ALWAYS( false && "TODO: MESH_REWORK" );
194     return 0;
195   }
196
197   int GetPropertyComponentIndex( Property::Index index ) const
198   {
199     // TODO: MESH_REWORK
200     DALI_ASSERT_ALWAYS( false && "TODO: MESH_REWORK" );
201     return 0;
202   }
203
204 };
205
206
207
208 } // namespace Internal
209
210 } // namespace Dali
211
212 #endif // DALI_INTERNAL_OBJECT_IMPL_HELPER_H