95d1a0336bc3921e038db108a3f9c65ecad4c1f9
[platform/core/uifw/dali-core.git] / capi / dali / public-api / object / base-object.h
1 #ifndef __DALI_BASE_OBJECT_H__
2 #define __DALI_BASE_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 /**
21  * @addtogroup CAPI_DALI_FRAMEWORK
22  * @{
23  */
24
25 // INTERNAL INCLUDES
26 #include <dali/public-api/object/ref-object.h>
27 #include <dali/public-api/object/base-handle.h>
28 #include <dali/public-api/object/property.h>
29 #include <dali/public-api/signals/functor-delegate.h>
30
31 namespace Dali DALI_IMPORT_API
32 {
33
34 class BaseHandle;
35
36 /**
37  * A base class for objects.
38  */
39 class BaseObject : public Dali::RefObject
40 {
41 public:
42
43   /**
44    * Connects a void() functor to a specified signal.
45    * @pre The signal must be available in this object.
46    * @param [in] connectionTracker A connection tracker which can be used to disconnect.
47    * @param [in] signalName Name of the signal to connect to.
48    * @param [in] functor The functor to copy.
49    * @return True if the signal was available.
50    */
51   template <class T>
52   bool ConnectSignal( ConnectionTrackerInterface* connectionTracker, const std::string& signalName, const T& functor )
53   {
54     return DoConnectSignal( connectionTracker, signalName, FunctorDelegate::New( functor ) );
55   }
56
57   /**
58    * @copydoc Dali::BaseHandle::DoAction
59    */
60   bool DoAction(const std::string& actionName, const std::vector<Property::Value>& attributes);
61
62   /**
63    * @copydoc Dali::BaseHandle::GetTypeName
64    */
65   const std::string& GetTypeName() const;
66
67 public: // Not intended for application developers
68
69   /**
70    * @copydoc Dali::BaseHandle::DoConnectSignal
71    */
72   bool DoConnectSignal( ConnectionTrackerInterface* connectionTracker, const std::string& signalName, FunctorDelegate* functorDelegate );
73
74 protected:
75
76   /**
77    * Default constructor.
78    */
79   BaseObject();
80
81   /**
82    * A reference counted object may only be deleted by calling Unreference()
83    */
84   virtual ~BaseObject();
85
86   /**
87    * Registers the object as created with the Object registry
88    */
89   void RegisterObject();
90
91   /**
92    * Unregisters the object from Object registry.
93    */
94   void UnregisterObject();
95
96 private:
97
98   // Not implemented
99   DALI_INTERNAL BaseObject(const BaseObject& rhs);
100
101   // Not implemented
102   DALI_INTERNAL BaseObject& operator=(const BaseObject& rhs);
103 };
104
105 // Helpers for public-api forwarding methods
106
107 inline BaseObject& GetImplementation(Dali::BaseHandle& object)
108 {
109   DALI_ASSERT_ALWAYS( object && "BaseObject handle is empty" );
110
111   return object.GetBaseObject();
112 }
113
114 inline const BaseObject& GetImplementation(const Dali::BaseHandle& object)
115 {
116   DALI_ASSERT_ALWAYS( object && "BaseObject handle is empty" );
117
118   return object.GetBaseObject();
119 }
120
121 } // namespace Dali
122
123 /**
124  * @}
125  */
126 #endif // __DALI_BASE_OBJECT_H__