Fix SINCE and DEPRECATED versions to be included in Tizen 5.5
[platform/core/uifw/dali-core.git] / dali / public-api / object / base-object.h
1 #ifndef __DALI_BASE_OBJECT_H__
2 #define __DALI_BASE_OBJECT_H__
3
4 /*
5  * Copyright (c) 2018 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/ref-object.h>
23 #include <dali/public-api/object/base-handle.h>
24 #include <dali/public-api/object/property.h>
25 #include <dali/public-api/signals/functor-delegate.h>
26
27 namespace Dali
28 {
29 /**
30  * @addtogroup dali_core_object
31  * @{
32  */
33
34 class BaseHandle;
35
36 /**
37  * @brief A base class for objects.
38  * @SINCE_1_0.0
39  */
40 class DALI_CORE_API BaseObject : public Dali::RefObject
41 {
42 public:
43
44   /**
45    * @brief Connects a void() functor to a specified signal.
46    *
47    * @SINCE_1_0.0
48    * @param[in] connectionTracker A connection tracker which can be used to disconnect
49    * @param[in] signalName Name of the signal to connect to
50    * @param[in] functor The functor to copy
51    * @return True if the signal was available
52    * @pre The signal must be available in this object.
53    */
54   template <class T>
55   bool ConnectSignal( ConnectionTrackerInterface* connectionTracker, const std::string& signalName, const T& functor )
56   {
57     return DoConnectSignal( connectionTracker, signalName, FunctorDelegate::New( functor ) );
58   }
59
60   /**
61    * @copydoc Dali::BaseHandle::DoAction
62    */
63   bool DoAction(const std::string& actionName, const Property::Map& attributes);
64
65   /**
66    * @copydoc Dali::BaseHandle::GetTypeName
67    */
68   const std::string& GetTypeName() const;
69
70   /**
71    * @copydoc Dali::BaseHandle::GetTypeInfo
72    */
73   bool GetTypeInfo(Dali::TypeInfo& info) const;
74
75 public: // Not intended for application developers
76
77   /**
78    * @brief Not intended for application developers.
79    *
80    * @SINCE_1_0.0
81    * @param[in] connectionTracker A connection tracker which can be used to disconnect
82    * @param[in] signalName Name of the signal to connect to
83    * @param[in] functorDelegate A newly allocated functor delegate (takes ownership)
84    * @return True if the signal was available
85    */
86   bool DoConnectSignal( ConnectionTrackerInterface* connectionTracker, const std::string& signalName, FunctorDelegate* functorDelegate );
87
88 protected:
89
90   /**
91    * @brief Default constructor.
92    * @SINCE_1_0.0
93    */
94   BaseObject();
95
96   /**
97    * @brief A reference counted object may only be deleted by calling Unreference().
98    * @SINCE_1_0.0
99    */
100   virtual ~BaseObject();
101
102   /**
103    * @brief Registers the object as created with the Object registry.
104    * @SINCE_1_0.0
105    */
106   void RegisterObject();
107
108   /**
109    * @brief Unregisters the object from Object registry.
110    * @SINCE_1_0.0
111    */
112   void UnregisterObject();
113
114 private:
115
116   // Not implemented
117   DALI_INTERNAL BaseObject(const BaseObject& rhs);
118
119   // Not implemented
120   DALI_INTERNAL BaseObject& operator=(const BaseObject& rhs);
121 };
122
123 // Helpers for public-api forwarding methods
124
125 /**
126  * @brief Gets the implementation of a handle.
127  *
128  * @SINCE_1_0.0
129  * @param[in] handle The handle
130  * @return A reference to the object the handle points at
131  */
132 inline BaseObject& GetImplementation(Dali::BaseHandle& handle)
133 {
134   DALI_ASSERT_ALWAYS( handle && "BaseObject handle is empty" );
135
136   return handle.GetBaseObject();
137 }
138
139 /**
140  * @brief Gets the implementation of a handle.
141  *
142  * @SINCE_1_0.0
143  * @param[in] handle The handle
144  * @return A reference to the object the handle points at
145  */
146 inline const BaseObject& GetImplementation(const Dali::BaseHandle& handle)
147 {
148   DALI_ASSERT_ALWAYS( handle && "BaseObject handle is empty" );
149
150   return handle.GetBaseObject();
151 }
152
153 /**
154  * @}
155  */
156 } // namespace Dali
157
158 # endif // __DALI_BASE_OBJECT_H__