95b6c30c67b08278fffff9b923f11acedfcfdffa
[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 ShaderFactory;
40 class GestureEventProcessor;
41 class RelayoutController;
42
43 namespace SceneGraph
44 {
45 class UpdateManager;
46 }
47
48 /**
49  * Class to store a pointer to core in thread local storage.
50  *
51  */
52 class ThreadLocalStorage
53 {
54 public:
55
56   /**
57    * Constructor
58    * Creates the TLS and adds a pointer to core
59    * @param [in] core reference to core
60    */
61   ThreadLocalStorage(Core* core);
62
63   /**
64    * Destructor.
65    */
66   ~ThreadLocalStorage();
67
68   /**
69    * Remove core pointer.
70    * Prevents the core pointer being automatically deleted when the thread exits.
71    */
72   void Remove();
73
74   /**
75    * Get the TLS
76    * @return reference to the TLS
77    */
78   static ThreadLocalStorage& Get();
79
80   /**
81    * Checks if the TLS has been created
82    * @return if the TLS has been created
83    */
84   static bool Created();
85
86   /**
87    * Get a pointer to the TLS or NULL if not initialized
88    * @return pointer to the TLS
89    */
90   static ThreadLocalStorage* GetInternal();
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 Shader Factory
112    * @return reference to the Shader Factory
113    */
114   ShaderFactory& GetShaderFactory();
115
116   /**
117    * Returns the current stage.
118    * @return A pointer to the current stage.
119    */
120   StagePtr GetCurrentStage();
121
122   /**
123    * Returns the gesture event processor.
124    * @return A reference to the gesture event processor.
125    */
126   GestureEventProcessor& GetGestureEventProcessor();
127
128   /**
129    * Return the relayout controller
130    * @Return Return a reference to the relayout controller
131    */
132   RelayoutController& GetRelayoutController();
133
134 private:
135
136   Core* mCore;                                              ///< reference to core
137
138 };
139
140 } // namespace Internal
141
142 } // namespace Dali
143
144 #endif // __DALI_INTERNAL_THREAD_LOCAL_STORAGE_H__