Gesture event refactor
[platform/core/uifw/dali-core.git] / dali / internal / event / common / thread-local-storage.cpp
1 /*
2  * Copyright (c) 2019 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 // CLASS HEADER
19 #include <dali/internal/event/common/thread-local-storage.h>
20
21 // INTERNAL INCLUDES
22 #include <dali/internal/common/core-impl.h>
23 #include <dali/public-api/common/dali-common.h>
24 #include <dali/internal/event/common/event-thread-services.h>
25
26 namespace Dali
27 {
28
29 namespace Internal
30 {
31
32 namespace
33 {
34 thread_local ThreadLocalStorage* threadLocal = nullptr;
35 }
36
37 ThreadLocalStorage::ThreadLocalStorage(Core* core)
38 : mCore( core )
39 {
40   DALI_ASSERT_ALWAYS( threadLocal == nullptr && "Cannot create more than one ThreadLocalStorage object" );
41
42   threadLocal = this;
43 }
44
45 ThreadLocalStorage::~ThreadLocalStorage()
46 {
47 }
48
49 void ThreadLocalStorage::Remove()
50 {
51   threadLocal = nullptr;
52 }
53
54 ThreadLocalStorage& ThreadLocalStorage::Get()
55 {
56   DALI_ASSERT_ALWAYS(threadLocal);
57
58   return *threadLocal;
59 }
60
61 bool ThreadLocalStorage::Created()
62 {
63   // see if the TLS has been set yet
64   return (threadLocal != nullptr);
65 }
66
67 ThreadLocalStorage* ThreadLocalStorage::GetInternal()
68 {
69   return threadLocal;
70 }
71
72 Dali::Integration::PlatformAbstraction& ThreadLocalStorage::GetPlatformAbstraction()
73 {
74   return mCore->GetPlatform();
75 }
76
77 SceneGraph::UpdateManager& ThreadLocalStorage::GetUpdateManager()
78 {
79   return mCore->GetUpdateManager();
80 }
81
82 NotificationManager& ThreadLocalStorage::GetNotificationManager()
83 {
84   return mCore->GetNotificationManager();
85 }
86
87 ShaderFactory& ThreadLocalStorage::GetShaderFactory()
88 {
89   return mCore->GetShaderFactory();
90 }
91
92 StagePtr ThreadLocalStorage::GetCurrentStage()
93 {
94   return mCore->GetCurrentStage();
95 }
96
97 GestureEventProcessor& ThreadLocalStorage::GetGestureEventProcessor()
98 {
99   return mCore->GetGestureEventProcessor();
100 }
101
102 RelayoutController& ThreadLocalStorage::GetRelayoutController()
103 {
104   return mCore->GetRelayoutController();
105 }
106
107 ObjectRegistry& ThreadLocalStorage::GetObjectRegistry()
108 {
109   return mCore->GetObjectRegistry();
110 }
111
112 EventThreadServices& ThreadLocalStorage::GetEventThreadServices()
113 {
114   return mCore->GetEventThreadServices();
115 }
116
117 PropertyNotificationManager& ThreadLocalStorage::GetPropertyNotificationManager()
118 {
119   return mCore->GetPropertyNotificationManager();
120 }
121
122 AnimationPlaylist& ThreadLocalStorage::GetAnimationPlaylist()
123 {
124   return mCore->GetAnimationPlaylist();
125 }
126
127 void ThreadLocalStorage::AddScene( Scene* scene )
128 {
129   mCore->AddScene( scene );
130 }
131
132 void ThreadLocalStorage::RemoveScene( Scene* scene )
133 {
134   mCore->RemoveScene( scene );
135 }
136
137 } // namespace Internal
138
139 } // namespace Dali