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/ref-object.h>
26 #include <dali/public-api/object/base-handle.h>
27 #include <dali/public-api/object/property.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
48 * @brief Connects a void() functor to a specified signal.
51 * @param[in] connectionTracker A connection tracker which can be used to disconnect
52 * @param[in] signalName Name of the signal to connect to
53 * @param[in] functor The functor to copy
54 * @return True if the signal was available
55 * @pre The signal must be available in this object.
58 bool ConnectSignal( ConnectionTrackerInterface* connectionTracker, const std::string& signalName, const T& functor )
60 return DoConnectSignal( connectionTracker, signalName, FunctorDelegate::New( functor ) );
64 * @copydoc Dali::BaseHandle::DoAction
66 bool DoAction(const std::string& actionName, const Property::Map& attributes);
69 * @copydoc Dali::BaseHandle::GetTypeName
71 const std::string& GetTypeName() const;
74 * @copydoc Dali::BaseHandle::GetTypeInfo
76 bool GetTypeInfo(Dali::TypeInfo& info) const;
78 public: // Not intended for application developers
81 * @brief Not intended for application developers.
84 * @param[in] connectionTracker A connection tracker which can be used to disconnect
85 * @param[in] signalName Name of the signal to connect to
86 * @param[in] functorDelegate A newly allocated functor delegate (takes ownership)
87 * @return True if the signal was available
89 bool DoConnectSignal( ConnectionTrackerInterface* connectionTracker, const std::string& signalName, FunctorDelegate* functorDelegate );
94 * @brief Default constructor.
100 * @brief A reference counted object may only be deleted by calling Unreference().
103 virtual ~BaseObject();
106 * @brief Registers the object as created with the Object registry.
109 void RegisterObject();
112 * @brief Unregisters the object from Object registry.
115 void UnregisterObject();
120 DALI_INTERNAL BaseObject(const BaseObject& rhs);
123 DALI_INTERNAL BaseObject& operator=(const BaseObject& rhs);
127 class DALI_INTERNAL Impl;
131 std::unique_ptr<Impl> mImpl;
134 // Helpers for public-api forwarding methods
137 * @brief Gets the implementation of a handle.
140 * @param[in] handle The handle
141 * @return A reference to the object the handle points at
143 inline BaseObject& GetImplementation(Dali::BaseHandle& handle)
145 DALI_ASSERT_ALWAYS( handle && "BaseObject handle is empty" );
147 return handle.GetBaseObject();
151 * @brief Gets the implementation of a handle.
154 * @param[in] handle The handle
155 * @return A reference to the object the handle points at
157 inline const BaseObject& GetImplementation(const Dali::BaseHandle& handle)
159 DALI_ASSERT_ALWAYS( handle && "BaseObject handle is empty" );
161 return handle.GetBaseObject();
169 # endif // __DALI_BASE_OBJECT_H__