c21c835a0a244964db17c63acad653dfc3ef07cb
[platform/core/uifw/dali-core.git] / dali / internal / event / common / event-thread-services.h
1 #ifndef __DALI_INTERNAL_EVENT_THREAD_SERVICES_H__
2 #define __DALI_INTERNAL_EVENT_THREAD_SERVICES_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 // EXTERNAL INCLUDES
22 #include <cstddef>
23
24 // INTERNAL INCLUDES
25 #include <dali/internal/common/buffer-index.h>
26
27 namespace Dali
28 {
29
30 class BaseObject;
31
32 namespace Integration
33 {
34 class RenderController;
35 }
36
37 namespace Internal
38 {
39
40 namespace SceneGraph
41 {
42 class UpdateManager;
43 }
44
45 /**
46  * Abstract interface of services for event-thread objects.
47  * Used for registering objects, queueing messages during the event-thread for the next update.
48  * Allows the event-thread to read double-buffered property values.
49  */
50 class EventThreadServices
51 {
52 public:
53
54   /**
55    * Virtual destructor
56    */
57   virtual ~EventThreadServices()
58   { }
59
60   /**
61    * @brief Registers the object as created with the Object registry.
62    *
63    * @param[in] object to register
64    */
65   virtual void RegisterObject( BaseObject* object) = 0;
66
67   /**
68    * @brief Unregisters the object from Object registry.
69    *
70    * @param[in] object to unregister
71    */
72   virtual void UnregisterObject( BaseObject* object) = 0;
73
74   /**
75    * @brief Get a reference to the UpdateManager
76    *
77    * @return the update manager
78    */
79   virtual SceneGraph::UpdateManager& GetUpdateManager() = 0;
80
81   /**
82    * @brief Get a reference to the RenderController
83    *
84    * @return the render controller
85    */
86   virtual Integration::RenderController& GetRenderController() = 0;
87
88   /**
89    * Reserve space for another message in the queue; this must then be initialized by the caller.
90    * The message will be read from the update-thread after the next FlushMessages is called.
91    * @post Calling this method may invalidate any previously returned slots.
92    * @param[in] size The message size with respect to the size of type "char".
93    * @param[in] updateScene A flag, when true denotes that the message will cause the scene-graph node tree to require an update.
94    * @return A pointer to the first char allocated for the message.
95    */
96   virtual unsigned int* ReserveMessageSlot( std::size_t size, bool updateScene = true ) = 0;
97
98   /**
99    * @return the current event-buffer index.
100    */
101   virtual BufferIndex GetEventBufferIndex() const  = 0;
102
103   /**
104    * @brief Indicate that the next rendering is really required.
105    */
106   virtual void ForceNextUpdate() = 0;
107
108   /**
109    * @brief Check if the next rendering is really required.
110    *
111    * @return true if the next rendering is really required.
112    */
113   virtual bool IsNextUpdateForced() = 0;
114
115   /**
116    * @return true if core is still running and we can send messages
117    */
118   static bool IsCoreRunning();
119 };
120
121 } // namespace Internal
122
123 } // namespace Dali
124
125 #endif // __DALI_INTERNAL_EVENT_THREAD_SERVICES_H__