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