1 #ifndef DALI_BASE_OBJECT_H
2 #define DALI_BASE_OBJECT_H
5 * Copyright (c) 2020 Samsung Electronics Co., Ltd.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
25 #include <dali/public-api/object/base-handle.h>
26 #include <dali/public-api/object/property.h>
27 #include <dali/public-api/object/ref-object.h>
28 #include <dali/public-api/signals/functor-delegate.h>
33 * @addtogroup dali_core_object
40 * @brief A base class for objects.
43 class DALI_CORE_API BaseObject : public Dali::RefObject
47 * @brief Connects a void() functor to a specified signal.
50 * @param[in] connectionTracker A connection tracker which can be used to disconnect
51 * @param[in] signalName Name of the signal to connect to
52 * @param[in] functor The functor to copy
53 * @return True if the signal was available
54 * @pre The signal must be available in this object.
57 bool ConnectSignal(ConnectionTrackerInterface* connectionTracker, const std::string& signalName, const T& functor)
59 return DoConnectSignal(connectionTracker, signalName, FunctorDelegate::New(functor));
63 * @copydoc Dali::BaseHandle::DoAction
65 bool DoAction(const std::string& actionName, const Property::Map& attributes);
68 * @copydoc Dali::BaseHandle::GetTypeName
70 const std::string& GetTypeName() const;
73 * @copydoc Dali::BaseHandle::GetTypeInfo
75 bool GetTypeInfo(Dali::TypeInfo& info) const;
77 public: // Not intended for application developers
79 * @brief Not intended for application developers.
82 * @param[in] connectionTracker A connection tracker which can be used to disconnect
83 * @param[in] signalName Name of the signal to connect to
84 * @param[in] functorDelegate A newly allocated functor delegate (takes ownership)
85 * @return True if the signal was available
87 bool DoConnectSignal(ConnectionTrackerInterface* connectionTracker, const std::string& signalName, FunctorDelegate* functorDelegate);
91 * @brief Default constructor.
97 * @brief A reference counted object may only be deleted by calling Unreference().
100 ~BaseObject() override;
103 * @brief Registers the object as created with the Object registry.
106 void RegisterObject();
109 * @brief Unregisters the object from Object registry.
112 void UnregisterObject();
114 // Not copyable or movable
116 BaseObject(const BaseObject& rhs) = delete; ///< Deleted copy constructor
117 BaseObject(BaseObject&& rhs) = delete; ///< Deleted move constructor
118 BaseObject& operator=(const BaseObject& rhs) = delete; ///< Deleted copy assignment operator
119 BaseObject& operator=(BaseObject&& rhs) = delete; ///< Deleted move assignment operator
122 class DALI_INTERNAL Impl;
125 std::unique_ptr<Impl> mImpl;
128 // Helpers for public-api forwarding methods
131 * @brief Gets the implementation of a handle.
134 * @param[in] handle The handle
135 * @return A reference to the object the handle points at
137 inline BaseObject& GetImplementation(Dali::BaseHandle& handle)
139 DALI_ASSERT_ALWAYS(handle && "BaseObject handle is empty");
141 return handle.GetBaseObject();
145 * @brief Gets the implementation of a handle.
148 * @param[in] handle The handle
149 * @return A reference to the object the handle points at
151 inline const BaseObject& GetImplementation(const Dali::BaseHandle& handle)
153 DALI_ASSERT_ALWAYS(handle && "BaseObject handle is empty");
155 return handle.GetBaseObject();
163 #endif // __DALI_BASE_OBJECT_H__