[SRUK] Initial copy from Tizen 2.2 version
[platform/core/uifw/dali-core.git] / dali / internal / event / common / object-impl.h
1 #ifndef __DALI_INTERNAL_OBJECT_H__
2 #define __DALI_INTERNAL_OBJECT_H__
3
4 //
5 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
6 //
7 // Licensed under the Flora License, Version 1.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://floralicense.org/license/
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 // INTERNAL INCLUDES
21 #include <dali/public-api/object/base-object.h>
22 #include <dali/public-api/object/handle.h>
23 #include <dali/public-api/object/property.h>
24
25 namespace Dali
26 {
27
28 class PropertyNotification;
29
30 namespace Internal
31 {
32 class Handle;
33
34 class PropertyCondition;
35
36 /**
37  * A base class for objects which optionally provide properties.
38  * The concrete derived class is responsible for implementing the property system methods.
39  * Classes may derive from Dali::BaseObject, until any properties are required.
40  */
41 class Object : public Dali::BaseObject
42 {
43 public:
44
45   typedef Dali::Handle::Capability Capability;
46
47   /**
48    * @copydoc Dali::Handle::Supports()
49    */
50   virtual bool Supports(Capability capability) const = 0;
51
52   /**
53    * @copydoc Dali::Handle::GetPropertyCount()
54    */
55   virtual unsigned int GetPropertyCount() const = 0;
56
57   /**
58    * @copydoc Dali::Handle::GetPropertyName()
59    */
60   virtual const std::string& GetPropertyName(Property::Index index) const = 0;
61
62   /**
63    * @copydoc Dali::Handle::GetPropertyIndex()
64    */
65   virtual Property::Index GetPropertyIndex(const std::string& name) const = 0;
66
67   /**
68    * @copydoc Dali::Handle::IsPropertyWritable()
69    */
70   virtual bool IsPropertyWritable(Property::Index index) const = 0;
71
72   /**
73    * @copydoc Dali::Handle::IsPropertyAnimatable()
74    */
75   virtual bool IsPropertyAnimatable(Property::Index index) const = 0;
76
77   /**
78    * @copydoc Dali::Handle::GetPropertyType()
79    */
80   virtual Property::Type GetPropertyType(Property::Index index) const = 0;
81
82   /**
83    * @copydoc Dali::Handle::SetProperty()
84    */
85   virtual void SetProperty(Property::Index index, const Property::Value& propertyValue) = 0;
86
87   /**
88    * @copydoc Dali::Handle::GetProperty()
89    */
90   virtual Property::Value GetProperty(Property::Index index) const = 0;
91
92   /**
93    * @copydoc Dali::Handle::RegisterProperty()
94    */
95   virtual Property::Index RegisterProperty(std::string name, const Property::Value& propertyValue) = 0;
96
97   /**
98    * @copydoc Dali::Handle::RegisterProperty(std::string name, Property::Value propertyValue, Property::AccessMode accessMode)
99    */
100   virtual Property::Index RegisterProperty(std::string name, const Property::Value& propertyValue, Property::AccessMode accessMode) = 0;
101
102   /**
103    * @copydoc Dali::Handle::AddPropertyNotification()
104    */
105   virtual Dali::PropertyNotification AddPropertyNotification(Property::Index index,
106                                                              const Dali::PropertyCondition& condition) = 0;
107
108   /**
109    * @copydoc Dali::Handle::AddPropertyNotification(Property::Index index, const PropertyCondition& condition, PropertyNotifyCallbackType callback)
110    */
111   virtual Dali::PropertyNotification AddPropertyNotification(Property::Index index,
112                                                              const Dali::PropertyCondition& condition,
113                                                              PropertyNotifyCallbackType callback) = 0;
114
115   /**
116    * @copydoc Dali::Handle::RemovePropertyNotification()
117    */
118   virtual void RemovePropertyNotification(Dali::PropertyNotification propertyNotification) = 0;
119
120   /**
121    * @copydoc Dali::Handle::RemovePropertyNotifications()
122    */
123   virtual void RemovePropertyNotifications() = 0;
124
125
126 protected:
127
128   /**
129    * Default constructor.
130    */
131   Object()
132   {
133   }
134
135   /**
136    * A reference counted object may only be deleted by calling Unreference()
137    */
138   virtual ~Object()
139   {
140   }
141
142 private:
143
144   // Not implemented
145   Object(const Object& rhs);
146
147   // Not implemented
148   Object& operator=(const Object& rhs);
149 };
150
151 } // namespace Internal
152
153 // Helpers for public-api forwarding methods
154
155 inline Internal::Object& GetImplementation(Dali::Handle& object)
156 {
157   DALI_ASSERT_ALWAYS( object && "Object handle is empty" );
158
159   BaseObject& handle = object.GetBaseObject();
160
161   return static_cast<Internal::Object&>(handle);
162 }
163
164 inline const Internal::Object& GetImplementation(const Dali::Handle& object)
165 {
166   DALI_ASSERT_ALWAYS( object && "Object handle is empty" );
167
168   const BaseObject& handle = object.GetBaseObject();
169
170   return static_cast<const Internal::Object&>(handle);
171 }
172
173 } // namespace Dali
174
175 #endif // __DALI_INTERNAL_OBJECT_H__
176