[dali_1.2.26] Merge branch 'devel/master'
[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) 2017 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
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 ResourceManager;
40 class ShaderFactory;
41 class GestureEventProcessor;
42 class RelayoutController;
43
44 namespace SceneGraph
45 {
46 class UpdateManager;
47 }
48
49 /**
50  * Class to store a pointer to core in thread local storage.
51  *
52  */
53 class ThreadLocalStorage
54 {
55 public:
56
57   /**
58    * Constructor
59    * Creates the TLS and adds a pointer to core
60    * @param [in] core reference to core
61    */
62   ThreadLocalStorage(Core* core);
63
64   /**
65    * Destructor.
66    */
67   ~ThreadLocalStorage();
68
69   /**
70    * Remove core pointer.
71    * Prevents the core pointer being automatically deleted when the thread exits.
72    */
73   void Remove();
74
75   /**
76    * Get the TLS
77    * @return reference to the TLS
78    */
79   static ThreadLocalStorage& Get();
80
81   /**
82    * Checks if the TLS has been created
83    * @return if the TLS has been created
84    */
85   static bool Created();
86
87   /**
88    * Get a pointer to the TLS or NULL if not initialized
89    * @return pointer to the TLS
90    */
91   static ThreadLocalStorage* GetInternal();
92
93   /**
94    * get platform abstraction
95    * @return reference to core
96    */
97   Dali::Integration::PlatformAbstraction& GetPlatformAbstraction();
98
99   /**
100    * Retrieve the update manager
101    * @return reference to update manager
102    */
103   SceneGraph::UpdateManager& GetUpdateManager();
104
105   /**
106    * Returns the Notification Manager
107    * @return reference to the Notification Manager
108    */
109   NotificationManager& GetNotificationManager();
110
111   /**
112    * Returns the Resource Manager
113    * @return reference to the Resource Manager
114    */
115   ResourceManager& GetResourceManager();
116
117   /**
118    * Returns the Shader Factory
119    * @return reference to the Shader Factory
120    */
121   ShaderFactory& GetShaderFactory();
122
123   /**
124    * Returns the current stage.
125    * @return A pointer to the current stage.
126    */
127   StagePtr GetCurrentStage();
128
129   /**
130    * Returns the gesture event processor.
131    * @return A reference to the gesture event processor.
132    */
133   GestureEventProcessor& GetGestureEventProcessor();
134
135   /**
136    * Return the relayout controller
137    * @Return Return a reference to the relayout controller
138    */
139   RelayoutController& GetRelayoutController();
140
141 private:
142
143   Core* mCore;                                              ///< reference to core
144
145 };
146
147 } // namespace Internal
148
149 } // namespace Dali
150
151 #endif // __DALI_INTERNAL_THREAD_LOCAL_STORAGE_H__