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