1 #ifndef DALI_INTERNAL_ADAPTOR_SYSTEM_WINDOWS_CALLBACK_MANAGER_H
2 #define DALI_INTERNAL_ADAPTOR_SYSTEM_WINDOWS_CALLBACK_MANAGER_H
5 * Copyright (c) 2023 Samsung Electronics Co., Ltd.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
22 #include <dali/public-api/common/list-wrapper.h>
25 #include <dali/internal/system/common/callback-manager.h>
33 struct WindowsCallbackData;
36 * @brief Windows callback manager used to install call backs in the applications main loop.
37 * The manager keeps track of all callbacks, so that if Stop() is called it can remove them.
39 class WinCallbackManager : public CallbackManager
50 ~WinCallbackManager();
53 * @copydoc CallbackManager::AddIdleCallback()
55 bool AddIdleCallback(CallbackBase* callback, bool hasReturnValue) override;
58 * @copydoc CallbackManager::RemoveIdleCallback()
60 void RemoveIdleCallback(CallbackBase* callback) override;
63 * @copydoc CallbackManager::ProcessIdle()
65 bool ProcessIdle() override;
68 * @copydoc CallbackManager::ClearIdleCallbacks()
70 void ClearIdleCallbacks() override;
73 * @brief Adds a @p callback to be run when entering an idle state.
74 * @note Must be called from the main thread only.
76 * A callback of the following type should be used:
80 * This callback will be called repeatedly as long as it returns true. A return of 0 deletes this callback.
82 * @param[in] callback custom callback function.
84 * @return true on success
86 bool AddIdleEntererCallback(CallbackBase* callback) override;
89 * @brief Removes a previously added the idle enterer callback.
90 * @note Must be called from main thread only.
92 * Does nothing if the @p callback doesn't exist.
94 * @param[in] callback The callback to be removed.
96 void RemoveIdleEntererCallback(CallbackBase* callback) override;
99 * @copydoc CallbackManager::Start()
101 void Start() override;
104 * @copydoc CallbackManager::Stop()
106 void Stop() override;
110 WinCallbackManager(const WinCallbackManager&) = delete;
111 WinCallbackManager& operator=(WinCallbackManager&) = delete;
114 * @brief Callback function comes from framework.
115 * It will be self callback.
117 void ProcessIdleFromFramework();
120 CallbackBase* mSelfCallback{nullptr};
121 bool mSelfCallbackRegistered{false}; ///< flag is set to true if we send processIdle callback register.
123 typedef std::list<WindowsCallbackData*> CallbackList;
125 CallbackList mCallbackContainer;
126 bool mRunning; ///< flag is set to true if when running
129 } // namespace Adaptor
131 } // namespace Internal
135 #endif // DALI_INTERNAL_ADAPTOR_SYSTEM_WINDOWS_CALLBACK_MANAGER_H