1 #ifndef __DALI_INTERNAL_OBJECT_REGISTRY_H__
2 #define __DALI_INTERNAL_OBJECT_REGISTRY_H__
5 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
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
11 // http://floralicense.org/license/
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.
22 #include <dali/public-api/common/set-wrapper.h>
24 #include <dali/public-api/object/ref-object.h>
25 #include <dali/public-api/object/object-registry.h>
26 #include <dali/public-api/object/base-object.h>
43 typedef IntrusivePtr<ObjectRegistry> ObjectRegistryPtr;
46 * The ObjectRegistry notifies it's observers when an object is created.
47 * There is a single instance of Object registry for each Dali-core instance.
48 * All Dali Objects need to register with ObjectRegistry to be observed by
49 * feedback plugin's and other observers.
51 class ObjectRegistry : public BaseObject
56 * Create the objectRegistry
58 static ObjectRegistryPtr New();
61 * Registers the Object into the Object Registry, Which notifies
62 * about this object creation to its observers.
63 * @pre The object is not already registered.
64 * @param[in] object Pointer to the object.
66 void RegisterObject( Dali::BaseObject* object );
69 * Unregisters the Object from the Object Registry, Which notifies
70 * about this object destruction to its observers.
71 * @pre The object is already registered.
72 * @param[in] object Pointer to the object.
74 void UnregisterObject( Dali::BaseObject* object );
77 * @copydoc Dali::ObjectRegistry::ObjectCreatedSignal()
79 Dali::ObjectRegistry::ObjectCreatedSignalV2& ObjectCreatedSignal()
81 return mObjectCreatedSignalV2;
85 * @copydoc Dali::ObjectRegistry::ObjectDestroyedSignal()
87 Dali::ObjectRegistry::ObjectDestroyedSignalV2& ObjectDestroyedSignal()
89 return mObjectDestroyedSignalV2;
93 * Connects a callback function with the object registry signals.
94 * @param[in] object The object providing the signal.
95 * @param[in] tracker Used to disconnect the signal.
96 * @param[in] signalName The signal to connect to.
97 * @param[in] functor A newly allocated FunctorDelegate.
98 * @return True if the signal was connected.
99 * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor.
101 static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor );
106 * Protected constructor; see also ObjectRegistry::New()
111 * A reference counted object may only be deleted by calling Unreference()
117 Dali::ObjectRegistry::ObjectCreatedSignalV2 mObjectCreatedSignalV2;
118 Dali::ObjectRegistry::ObjectDestroyedSignalV2 mObjectDestroyedSignalV2;
121 std::set< Dali::BaseObject* > mDebugRegistry; ///< This allows us to assert that an object is only registered once (debug builds only)
126 } // namespace Internal
128 // Helpers for public-api forwarding methods
130 inline Internal::ObjectRegistry& GetImplementation(Dali::ObjectRegistry& objectRegistry)
132 DALI_ASSERT_ALWAYS( objectRegistry && "ObjectRegistry handle is empty" );
134 BaseObject& handle = objectRegistry.GetBaseObject();
136 return static_cast<Internal::ObjectRegistry&>(handle);
139 inline const Internal::ObjectRegistry& GetImplementation(const Dali::ObjectRegistry& objectRegistry)
141 DALI_ASSERT_ALWAYS( objectRegistry && "ObjectRegistry handle is empty" );
143 const BaseObject& handle = objectRegistry.GetBaseObject();
145 return static_cast<const Internal::ObjectRegistry&>(handle);
150 #endif // __DALI_INTERNAL_OBJECT_REGISTRY_H__