[dali_1.0.1] Merge branch 'tizen'
[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 platform abstraction
94    * @return reference to core
95    */
96   Dali::Integration::PlatformAbstraction& GetPlatformAbstraction();
97
98   /**
99    * Retrieve the update manager
100    * @return reference to update manager
101    */
102   SceneGraph::UpdateManager& GetUpdateManager();
103
104   /**
105    * Returns the Notification Manager
106    * @return reference to the Notification Manager
107    */
108   NotificationManager& GetNotificationManager();
109
110   /**
111    * Returns the Resource Manager
112    * @return reference to the Resource Manager
113    */
114   ResourceManager& GetResourceManager();
115
116   /**
117    * Returns the Resource Client
118    * @return reference to the Resource Client
119    */
120   ResourceClient& GetResourceClient();
121
122   /**
123    * Returns the Image Factory
124    * @return reference to the Image Factory
125    */
126   ImageFactory& GetImageFactory();
127
128   /**
129    * Returns the Model Factory
130    * @return reference to the Image Factory
131    */
132   ModelFactory& GetModelFactory();
133
134   /**
135    * Returns the Font Factory
136    * @return reference to the Font Factory
137    */
138   FontFactory& GetFontFactory();
139
140   /**
141    * Returns the Shader Factory
142    * @return reference to the Shader Factory
143    */
144   ShaderFactory& GetShaderFactory();
145
146   /**
147    * Returns the current stage.
148    * @return A smart-pointer to the current stage.
149    */
150   StagePtr GetCurrentStage();
151
152   /**
153    * Return the message controller
154    * @return A reference to the message controller
155    */
156   EventToUpdate& GetEventToUpdate();
157
158   /**
159    * Returns the gesture event processor.
160    * @return A reference to the gesture event processor.
161    */
162   GestureEventProcessor& GetGestureEventProcessor();
163
164   /**
165    * Returns the Emoji factory.
166    * @return a reference to the Emoji factory.
167    */
168   EmojiFactory& GetEmojiFactory();
169
170 private:
171
172   Core* mCore;                            ///< reference to core
173
174 };
175
176 } // namespace Internal
177
178 } // namespace Dali
179
180 #endif // __DALI_INTERNAL_THREAD_LOCAL_STORAGE_H__