Merge remote-tracking branch 'origin/tizen' into new_text
[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 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( const 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( const 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 protected:
131
132   /**
133    * Default constructor.
134    */
135   Object()
136   {
137   }
138
139   /**
140    * A reference counted object may only be deleted by calling Unreference()
141    */
142   virtual ~Object()
143   {
144   }
145
146 private:
147
148   // Not implemented
149   Object(const Object& rhs);
150
151   // Not implemented
152   Object& operator=(const Object& rhs);
153 };
154
155 } // namespace Internal
156
157 // Helpers for public-api forwarding methods
158
159 inline Internal::Object& GetImplementation(Dali::Handle& object)
160 {
161   DALI_ASSERT_ALWAYS( object && "Object handle is empty" );
162
163   BaseObject& handle = object.GetBaseObject();
164
165   return static_cast<Internal::Object&>(handle);
166 }
167
168 inline const Internal::Object& GetImplementation(const Dali::Handle& object)
169 {
170   DALI_ASSERT_ALWAYS( object && "Object handle is empty" );
171
172   const BaseObject& handle = object.GetBaseObject();
173
174   return static_cast<const Internal::Object&>(handle);
175 }
176
177 } // namespace Dali
178
179 #endif // __DALI_INTERNAL_OBJECT_H__
180