Merge "Remove extension from shader." into devel/new_mesh
[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-def.h>
23 #ifdef DYNAMICS_SUPPORT
24 #include <dali/internal/event/dynamics/dynamics-world-impl.h>
25 #endif
26
27 namespace Dali
28 {
29
30 struct Vector2;
31
32 namespace Integration
33 {
34 class PlatformAbstraction;
35 }
36
37 namespace Internal
38 {
39
40 class Core;
41 class NotificationManager;
42 class ResourceClient;
43 class ResourceManager;
44 class ImageFactory;
45 class ShaderFactory;
46 class GestureEventProcessor;
47 class RelayoutController;
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 #ifdef DYNAMICS_SUPPORT
105   /**
106    * Get DynamicsWorld instance
107    * @return A pointer to the current DynamicsWorld.
108    */
109   Dali::Internal::DynamicsWorldPtr GetDynamicsWorldInstance();
110 #endif
111
112   /**
113    * Retrieve the update manager
114    * @return reference to update manager
115    */
116   SceneGraph::UpdateManager& GetUpdateManager();
117
118   /**
119    * Returns the Notification Manager
120    * @return reference to the Notification Manager
121    */
122   NotificationManager& GetNotificationManager();
123
124   /**
125    * Returns the Resource Manager
126    * @return reference to the Resource Manager
127    */
128   ResourceManager& GetResourceManager();
129
130   /**
131    * Returns the Resource Client
132    * @return reference to the Resource Client
133    */
134   ResourceClient& GetResourceClient();
135
136   /**
137    * Returns the Image Factory
138    * @return reference to the Image Factory
139    */
140   ImageFactory& GetImageFactory();
141
142   /**
143    * Returns the Shader Factory
144    * @return reference to the Shader Factory
145    */
146   ShaderFactory& GetShaderFactory();
147
148   /**
149    * Returns the current stage.
150    * @return A pointer to the current stage.
151    */
152   StagePtr GetCurrentStage();
153
154   /**
155    * Returns the gesture event processor.
156    * @return A reference to the gesture event processor.
157    */
158   GestureEventProcessor& GetGestureEventProcessor();
159
160   /**
161    * Return the relayout controller
162    * @Return Return a reference to the relayout controller
163    */
164   RelayoutController& GetRelayoutController();
165
166 private:
167
168   Core* mCore;                                              ///< reference to core
169 #ifdef DYNAMICS_SUPPORT
170   Dali::Internal::DynamicsWorldPtr mDynamicsWorldInstance;  ///< Instance of DynamicsWorld (This does not need to be in core)
171 #endif
172
173 };
174
175 } // namespace Internal
176
177 } // namespace Dali
178
179 #endif // __DALI_INTERNAL_THREAD_LOCAL_STORAGE_H__