removal of unnecessary exports; math & object.. 15 exports less
[platform/core/uifw/dali-core.git] / dali / public-api / object / object-registry.h
1 #ifndef __DALI_OBJECT_REGISTRY_H__
2 #define __DALI_OBJECT_REGISTRY_H__
3
4 /*
5  * Copyright (c) 2014 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 // EXTERNAL INCLUDES
22 #include <boost/function.hpp>
23
24 // INTERNAL INCLUDES
25 #include <dali/public-api/object/handle.h>
26 #include <dali/public-api/signals/dali-signal-v2.h>
27
28 namespace Dali
29 {
30
31 namespace Internal DALI_INTERNAL
32 {
33 class ObjectRegistry;
34 }
35
36 /**
37  * @brief The ObjectRegistry notifies it's observers when an object is created.
38  *
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.
42  *
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
46  *
47  * Usage:
48  * ObjectRegistry registry = Stage::GetObjectRegistry();
49  * registry.ObjectCreatedSignal().Connect( ObjectCreatedCallbackFunc );
50  *
51  */
52 class DALI_IMPORT_API ObjectRegistry : public BaseHandle
53 {
54 public:
55
56   //Signal Names
57   static const char* const SIGNAL_OBJECT_CREATED;   ///< Created signal name
58   static const char* const SIGNAL_OBJECT_DESTROYED; ///< Destroyed signal name
59
60   // Typedefs
61
62   /**
63    * @brief Object created signal
64    */
65   typedef SignalV2<  void (BaseHandle) > ObjectCreatedSignalV2;
66
67   /**
68    * @brief Object destroyed signal
69    */
70   typedef SignalV2<  void (const Dali::RefObject*) > ObjectDestroyedSignalV2;
71
72   /**
73    * @brief Allows the creation of an empty objectRegistry handle.
74    *
75    * To retrieve the current objectRegistry,
76    * this handle can be set using Stage::GetCurrent().GetObjectRegistry().
77    */
78   ObjectRegistry();
79
80   /**
81    * @brief Destructor
82    *
83    * This is non-virtual since derived Handle types must not contain data or virtual methods.
84    */
85   ~ObjectRegistry();
86
87   /**
88    * @brief This copy constructor is required for (smart) pointer semantics.
89    *
90    * @param [in] handle A reference to the copied handle
91    */
92   ObjectRegistry(const ObjectRegistry& handle);
93
94   /**
95    * @brief This assignment operator is required for (smart) pointer semantics.
96    *
97    * @param [in] rhs  A reference to the copied handle
98    * @return A reference to this
99    */
100   ObjectRegistry& operator=(const ObjectRegistry& rhs);
101
102   /**
103    * @brief This method is defined to allow assignment of the NULL value,
104    * and will throw an exception if passed any other value.
105    *
106    * Assigning to NULL is an alias for Reset().
107    * @param [in] rhs  A NULL pointer
108    * @return A reference to this handle
109    */
110   ObjectRegistry& operator=(BaseHandle::NullType* rhs);
111
112 public: // Signals
113
114   /**
115    * @brief This signal is emitted when an object is created.
116    *
117    * A callback of the following type may be connected:
118    * @code
119    *   void YourCallbackName(BaseHandle object);
120    * @endcode
121    * @pre The Object has been initialized.
122    * @return The signal to connect to.
123    */
124   ObjectCreatedSignalV2& ObjectCreatedSignal();
125
126   /**
127    * @brief This signal is emitted when an object is destroyed.
128    *
129    * WARNING: Since this signal is emitted when the object is
130    * in the process of being destroyed, the RefObject pointer
131    * passed in the signal should not be modified in anyways.
132    * And should NOT be used to create an handle. which will
133    * affect the life time of this destroyed object and leads to
134    * undefined behaviour.
135    *
136    * The only intended use is for Toolkit controls which want to
137    * keep track of objects being created and destroyed for internal
138    * bookkeeping.
139    *
140    * A callback of the following type may be connected:
141    * @code
142    *   void YourCallbackName(const Dali::RefObject* objectPointer);
143    * @endcode
144    * @pre The Object has been initialized.
145    * @return The signal to connect to.
146    */
147   ObjectDestroyedSignalV2& ObjectDestroyedSignal();
148
149 public: // Not intended for application developers
150
151   /**
152    * @brief This constructor is used by Dali Get() method.
153    *
154    * @param [in] objectRegistry A pointer to a Dali resource
155    */
156   explicit DALI_INTERNAL ObjectRegistry(Internal::ObjectRegistry* objectRegistry);
157 };
158
159 } // namespace Dali
160
161 #endif // __DALI_OBJECT_REGISTRY_H__