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