Dali 3D User Interface Engine
object-impl.h
Go to the documentation of this file.
1 #ifndef __DALI_INTERNAL_OBJECT_H__
2 #define __DALI_INTERNAL_OBJECT_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 // INTERNAL INCLUDES
36 
37 namespace Dali
38 {
39 
40 class PropertyNotification;
41 
42 namespace Internal
43 {
44 class ConstraintBase;
45 class EventThreadServices;
46 class Handle;
47 class PropertyCondition;
48 class PropertyInputImpl;
49 class Stage;
50 class TypeInfo;
51 
52 namespace SceneGraph
53 {
54 class PropertyBase;
55 class PropertyOwner;
56 }
57 
58 typedef std::vector< Dali::Constraint > ConstraintContainer;
59 typedef ConstraintContainer::iterator ConstraintIter;
60 typedef ConstraintContainer::const_iterator ConstraintConstIter;
61 
62 
79 class Object : public Dali::BaseObject
80 {
81 public:
82 
84 
85  class Observer
86  {
87  public:
88 
93  virtual void SceneObjectAdded(Object& object) = 0;
94 
99  virtual void SceneObjectRemoved(Object& object) = 0;
100 
105  virtual void ObjectDestroyed(Object& object) = 0;
106 
107  protected:
108 
112  virtual ~Observer(){}
113  };
114 
118  Object();
119 
124  virtual void AddObserver( Observer& observer );
125 
131  virtual void RemoveObserver( Observer& observer );
132 
136  virtual bool Supports( Capability capability ) const;
137 
141  virtual unsigned int GetPropertyCount() const;
142 
146  virtual std::string GetPropertyName( Property::Index index ) const;
147 
151  virtual Property::Index GetPropertyIndex( const std::string& name ) const;
152 
156  virtual bool IsPropertyWritable( Property::Index index ) const;
157 
161  virtual bool IsPropertyAnimatable( Property::Index index ) const;
162 
166  virtual bool IsPropertyAConstraintInput( Property::Index index ) const;
167 
171  virtual Property::Type GetPropertyType( Property::Index index ) const;
172 
176  virtual void SetProperty( Property::Index index, const Property::Value& propertyValue );
177 
181  virtual Property::Value GetProperty( Property::Index index ) const;
182 
186  virtual void GetPropertyIndices( Property::IndexContainer& indices ) const;
187 
191  virtual Property::Index RegisterProperty( const std::string& name, const Property::Value& propertyValue );
192 
196  virtual Property::Index RegisterProperty( const std::string& name, const Property::Value& propertyValue, Property::AccessMode accessMode );
197 
202  int componentIndex,
203  const Dali::PropertyCondition& condition );
204 
208  virtual void RemovePropertyNotification( Dali::PropertyNotification propertyNotification );
209 
213  virtual void RemovePropertyNotifications();
214 
215  /******************************** Uniform Mappings ********************************/
216 
220  void AddUniformMapping( Property::Index propertyIndex, const std::string& uniformName ) const;
221 
225  void RemoveUniformMapping( const std::string& uniformName );
226 
227  /******************************** Constraints ********************************/
228 
233  void ApplyConstraint( ConstraintBase& constraint );
234 
239  void RemoveConstraint( ConstraintBase& constraint );
240 
244  void RemoveConstraints();
245 
249  void RemoveConstraints( unsigned int tag );
250 
255  void SetTypeInfo( const TypeInfo* typeInfo );
256 
261  {
263  }
264 
265  /******************** To be overridden by deriving classes ********************/
266 
271  virtual const SceneGraph::PropertyOwner* GetSceneObject() const = 0;
272 
280 
287  virtual const PropertyInputImpl* GetSceneObjectInputProperty( Property::Index index ) const = 0;
288 
295  virtual int GetPropertyComponentIndex( Property::Index index ) const;
296 
297 protected:
298 
302  virtual ~Object();
303 
307  void OnSceneObjectAdd();
308 
312  void OnSceneObjectRemove();
313 
320  virtual void OnPropertySet( Property::Index index, Property::Value propertyValue ) {}
321 
327  const TypeInfo* GetTypeInfo() const;
328 
335 
342 
350  Property::Index RegisterSceneGraphProperty(const std::string& name, Property::Index index, const Property::Value& propertyValue) const;
351 
358 
359 private: // Default property extensions for derived classes
360 
365  virtual unsigned int GetDefaultPropertyCount() const = 0;
366 
372  virtual void GetDefaultPropertyIndices( Property::IndexContainer& indices ) const = 0;
373 
378  virtual const char* GetDefaultPropertyName( Property::Index index ) const = 0;
379 
385  virtual Property::Index GetDefaultPropertyIndex( const std::string& name ) const = 0;
386 
392  virtual bool IsDefaultPropertyWritable( Property::Index index ) const = 0;
393 
400  virtual bool IsDefaultPropertyAnimatable( Property::Index index ) const = 0;
401 
408  virtual bool IsDefaultPropertyAConstraintInput( Property::Index index ) const = 0;
409 
415  virtual Property::Type GetDefaultPropertyType( Property::Index index ) const = 0;
416 
423  virtual void SetDefaultProperty( Property::Index index, const Property::Value& propertyValue ) = 0;
424 
430  virtual Property::Value GetDefaultProperty( Property::Index index ) const = 0;
431 
439  {
440  return GetSceneObject();
441  }
442 
450  virtual void NotifyScenePropertyInstalled( const SceneGraph::PropertyBase& newProperty, const std::string& name, unsigned int index ) const
451  { }
452 
453 private:
454 
455  // Not implemented
456  Object(const Object& rhs);
457 
458  // Not implemented
459  Object& operator=(const Object& rhs);
460 
465 
470 
476  Property::Value GetPropertyValue( const PropertyMetadata* entry ) const;
477 
484  virtual void SetSceneGraphProperty( Property::Index index, const PropertyMetadata& entry, const Property::Value& value );
485 
486 protected:
495  {
497  return mEventThreadServices;
498  }
499 
508  {
510  return mEventThreadServices;
511  }
512 
513 private:
515 
516 private:
517 
521  mutable TypeInfo const * mTypeInfo;
522 
524 
526 
527  typedef std::vector< Dali::PropertyNotification > PropertyNotificationContainer;
528  typedef PropertyNotificationContainer::iterator PropertyNotificationContainerIter;
529  typedef PropertyNotificationContainer::const_iterator PropertyNotificationContainerConstIter;
531 };
532 } // namespace Internal
533 
534 // Helpers for public-api forwarding methods
535 
537 {
538  DALI_ASSERT_ALWAYS( object && "Object handle is empty" );
539 
540  BaseObject& handle = object.GetBaseObject();
541 
542  return static_cast<Internal::Object&>(handle);
543 }
544 
545 inline const Internal::Object& GetImplementation(const Dali::Handle& object)
546 {
547  DALI_ASSERT_ALWAYS( object && "Object handle is empty" );
548 
549  const BaseObject& handle = object.GetBaseObject();
550 
551  return static_cast<const Internal::Object&>(handle);
552 }
553 
554 } // namespace Dali
555 
556 #endif // __DALI_INTERNAL_OBJECT_H__
Dali Docs Home
Read more about Dali