Dali 3D User Interface Engine
type-info-impl.h
Go to the documentation of this file.
1 #ifndef __DALI_INTERNAL_TYPE_INFO_H__
2 #define __DALI_INTERNAL_TYPE_INFO_H__
3 
4 /*
5  * Copyright (c) 2015 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 // EXTERNAL INCLUDES
22 #include <string>
23 
24 // INTERNAL INCLUDES
28 
29 namespace Dali
30 {
31 
32 namespace Internal
33 {
34 
42 class TypeInfo : public BaseObject
43 {
44 public:
51  TypeInfo(const std::string &name, const std::string &baseName, Dali::TypeInfo::CreateFunction creator);
52 
56  ~TypeInfo();
57 
61  const std::string& GetName() const;
62 
66  const std::string& GetBaseName() const;
67 
71  BaseHandle CreateInstance() const;
72 
77 
81  size_t GetActionCount() const;
82 
86  std::string GetActionName(size_t index) const;
87 
91  size_t GetSignalCount() const;
92 
96  std::string GetSignalName(size_t index) const;
97 
101  size_t GetPropertyCount() const;
102 
106  std::string GetPropertyName(size_t index) const;
107 
112  void GetPropertyIndices( Property::IndexContainer& indices ) const;
113 
117  const std::string& GetPropertyName( Property::Index index ) const;
118 
119  /*
120  * Add an action function
121  */
122  void AddActionFunction( const std::string &actionName, Dali::TypeInfo::ActionFunction function );
123 
124  /*
125  * Add a function for connecting a signal.
126  * @param[in] signalName The name of the signal.
127  * @param[in] function The function used for connecting to the signal.
128  */
129  void AddConnectorFunction( const std::string& signalName, Dali::TypeInfo::SignalConnectorFunction function );
130 
139  void AddProperty( const std::string& name, Property::Index index, Property::Type type, Dali::TypeInfo::SetPropertyFunction setFunc, Dali::TypeInfo::GetPropertyFunction getFunc );
140 
147  void AddAnimatableProperty( const std::string& name, Property::Index index, Property::Type type );
148 
155  void AddAnimatableProperty( const std::string& name, Property::Index index, const Property::Value& defaultValue );
156 
165  void AddAnimatablePropertyComponent( const std::string& name, Property::Index index, Property::Index baseIndex, unsigned int componentIndex );
166 
174  bool DoActionTo(BaseObject *object, const std::string &actionName, const Property::Map &properties);
175 
185  bool ConnectSignal( BaseObject* object, ConnectionTrackerInterface* connectionTracker, const std::string& signalName, FunctorDelegate* functor );
186 
192  Property::Index GetPropertyIndex( const std::string& name ) const;
193 
200 
206  int GetComponentIndex( Property::Index index ) const;
207 
213  bool IsPropertyWritable( Property::Index index ) const;
214 
221 
228 
235  void SetProperty( BaseObject *object, Property::Index index, const Property::Value& value ) const;
236 
243  void SetProperty( BaseObject *object, const std::string& name, const Property::Value& value ) const;
244 
251  Property::Value GetProperty( const BaseObject *object, Property::Index index ) const;
252 
259  Property::Value GetProperty( const BaseObject *object, const std::string& name ) const;
260 
261 private:
262 
264  {
266  : type( Property::NONE ),
267  setFunc( NULL ),
268  getFunc( NULL ),
269  name(),
270  basePropertyIndex(Property::INVALID_INDEX),
271  componentIndex(Property::INVALID_COMPONENT_INDEX)
272  {
273  }
274 
276  : type( propType ),
277  setFunc( set ),
278  getFunc( get ),
279  name( propName ),
280  basePropertyIndex(basePropertyIndex),
281  componentIndex(componentIndex)
282  {
283  }
284 
288  std::string name;
291  };
292 
293  typedef std::pair<std::string, Dali::TypeInfo::SignalConnectorFunction > ConnectionPair;
294  typedef std::pair<std::string, Dali::TypeInfo::ActionFunction > ActionPair;
295  typedef std::pair<Property::Index, RegisteredProperty> RegisteredPropertyPair;
296  typedef std::pair<Property::Index, Property::Value> PropertyDefaultValuePair;
297 
298  typedef std::vector< ActionPair > ActionContainer;
299  typedef std::vector< ConnectionPair > ConnectorContainer;
300  typedef std::vector< RegisteredPropertyPair > RegisteredPropertyContainer;
301  typedef std::vector< PropertyDefaultValuePair > PropertyDefaultValueContainer;
302 
303  std::string mTypeName;
304  std::string mBaseTypeName;
310 };
311 
312 } // namespace Internal
313 
314 // Helpers for public-api forwarding methods
315 
317 {
318  DALI_ASSERT_ALWAYS(typeInfo);
319 
320  BaseObject& handle = typeInfo.GetBaseObject();
321 
322  return static_cast<Internal::TypeInfo&>(handle);
323 }
324 
326 {
327  DALI_ASSERT_ALWAYS(typeInfo);
328 
329  const BaseObject& handle = typeInfo.GetBaseObject();
330 
331  return static_cast<const Internal::TypeInfo&>(handle);
332 }
333 
334 } // namespace Dali
335 
336 #endif // header
Dali Docs Home
Read more about Dali