[SRUK] Initial copy from Tizen 2.2 version
[platform/core/uifw/dali-core.git] / dali / internal / event / common / thread-local-storage.h
1 #ifndef __DALI_INTERNAL_THREAD_LOCAL_STORAGE_H__
2 #define __DALI_INTERNAL_THREAD_LOCAL_STORAGE_H__
3
4 //
5 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
6 //
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
10 //
11 //     http://floralicense.org/license/
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 // INTERNAL INCLUDES
21 #include <dali/internal/event/common/stage-impl.h>
22
23 namespace Dali
24 {
25
26 struct Vector2;
27
28 namespace Integration
29 {
30 class PlatformAbstraction;
31 }
32
33 namespace Internal
34 {
35
36 class Core;
37 class NotificationManager;
38 class ResourceClient;
39 class ResourceManager;
40 class ImageFactory;
41 class ModelFactory;
42 class FontFactory;
43 class ShaderFactory;
44 class EventToUpdate;
45 class GestureEventProcessor;
46
47 namespace SceneGraph
48 {
49 class UpdateManager;
50 }
51
52 /**
53  * Class to store a pointer to core in thread local storage.
54  *
55  */
56 class ThreadLocalStorage
57 {
58 public:
59
60   /**
61    * Constructor
62    * Creates the TLS and adds a pointer to core
63    * @param [in] core reference to core
64    */
65   ThreadLocalStorage(Core* core);
66
67   /**
68    * Destructor.
69    */
70   ~ThreadLocalStorage();
71
72   /**
73    * Remove core pointer.
74    * Prevents the core pointer being automatically deleted when the thread exits.
75    */
76   void Remove();
77
78   /**
79    * Get the TLS
80    * @return reference to the TLS
81    */
82   static ThreadLocalStorage& Get();
83
84   /**
85    * Checks if the TLS has been created
86    * @return if the TLS has been created
87    */
88   static bool Created();
89
90   /**
91    * get platform abstraction
92    * @return reference to core
93    */
94   Dali::Integration::PlatformAbstraction& GetPlatformAbstraction();
95
96   /**
97    * Retrieve the update manager
98    * @return reference to update manager
99    */
100   SceneGraph::UpdateManager& GetUpdateManager();
101
102   /**
103    * Returns the Notification Manager
104    * @return reference to the Notification Manager
105    */
106   NotificationManager& GetNotificationManager();
107
108   /**
109    * Returns the Resource Manager
110    * @return reference to the Resource Manager
111    */
112   ResourceManager& GetResourceManager();
113
114   /**
115    * Returns the Resource Client
116    * @return reference to the Resource Client
117    */
118   ResourceClient& GetResourceClient();
119
120   /**
121    * Returns the Image Factory
122    * @return reference to the Image Factory
123    */
124   ImageFactory& GetImageFactory();
125
126   /**
127    * Returns the Model Factory
128    * @return reference to the Image Factory
129    */
130   ModelFactory& GetModelFactory();
131
132   /**
133    * Returns the Font Factory
134    * @return reference to the Font Factory
135    */
136   FontFactory& GetFontFactory();
137
138   /**
139    * Returns the Shader Factory
140    * @return reference to the Shader Factory
141    */
142   ShaderFactory& GetShaderFactory();
143
144   /**
145    * Returns the current stage.
146    * @return A smart-pointer to the current stage.
147    */
148   StagePtr GetCurrentStage();
149
150   /**
151    * Return the message controller
152    * @return A reference to the message controller
153    */
154   EventToUpdate& GetEventToUpdate();
155
156   /**
157    * Returns the gesture event processor.
158    * @return A reference to the gesture event processor.
159    */
160   GestureEventProcessor& GetGestureEventProcessor();
161
162 private:
163
164   Core* mCore;                            ///< reference to core
165
166 };
167
168 } // namespace Internal
169
170 } // namespace Dali
171
172 #endif // __DALI_INTERNAL_THREAD_LOCAL_STORAGE_H__