1 #ifndef __DALI_OBJECT_REGISTRY_H__
2 #define __DALI_OBJECT_REGISTRY_H__
5 * Copyright (c) 2014 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.
22 #include <boost/function.hpp>
25 #include <dali/public-api/object/handle.h>
26 #include <dali/public-api/signals/dali-signal-v2.h>
28 namespace Dali DALI_IMPORT_API
31 namespace Internal DALI_INTERNAL
37 * @brief The ObjectRegistry notifies it's observers when an object is created.
39 * Handle to the created Object is passed in the call back function.
40 * The Handle is passed as Dali::Object handle, which can be DownCast
41 * to the appropriate type.
43 * Care should be taken to not store the handle in the Observer, as this will
44 * have adverse effect on the life time of the Internal Object. The Handle
45 * should only be used to connect to signals
48 * ObjectRegistry registry = Stage::GetObjectRegistry();
49 * registry.ObjectCreatedSignal().Connect( ObjectCreatedCallbackFunc );
52 class ObjectRegistry : public BaseHandle
57 static const char* const SIGNAL_OBJECT_CREATED; ///< Created signal name
58 static const char* const SIGNAL_OBJECT_DESTROYED; ///< Destroyed signal name
63 * @brief Object created signal
65 typedef SignalV2< void (BaseHandle) > ObjectCreatedSignalV2;
68 * @brief Object destroyed signal
70 typedef SignalV2< void (const Dali::RefObject*) > ObjectDestroyedSignalV2;
73 * @brief Allows the creation of an empty objectRegistry handle.
75 * To retrieve the current objectRegistry,
76 * this handle can be set using Stage::GetCurrent().GetObjectRegistry().
83 * This is non-virtual since derived Handle types must not contain data or virtual methods.
88 * @copydoc Dali::BaseHandle::operator=
90 using BaseHandle::operator=;
95 * @brief This signal is emitted when an object is created.
97 * A callback of the following type may be connected:
99 * void YourCallbackName(BaseHandle object);
101 * @pre The Object has been initialized.
102 * @return The signal to connect to.
104 ObjectCreatedSignalV2& ObjectCreatedSignal();
107 * @brief This signal is emitted when an object is destroyed.
109 * WARNING: Since this signal is emitted when the object is
110 * in the process of being destroyed, the RefObject pointer
111 * passed in the signal should not be modified in anyways.
112 * And should NOT be used to create an handle. which will
113 * affect the life time of this destroyed object and leads to
114 * undefined behaviour.
116 * The only intended use is for Toolkit controls which want to
117 * keep track of objects being created and destroyed for internal
120 * A callback of the following type may be connected:
122 * void YourCallbackName(const Dali::RefObject* objectPointer);
124 * @pre The Object has been initialized.
125 * @return The signal to connect to.
127 ObjectDestroyedSignalV2& ObjectDestroyedSignal();
129 public: // Not intended for application developers
132 * @brief This constructor is used by Dali Get() method.
134 * @param [in] objectRegistry A pointer to a Dali resource
136 explicit DALI_INTERNAL ObjectRegistry(Internal::ObjectRegistry* objectRegistry);
141 #endif // __DALI_OBJECT_REGISTRY_H__