1 #ifndef DALI_EXTENSION_INTERNAL_RIVE_ANIMATION_MANAGER_H
2 #define DALI_EXTENSION_INTERNAL_RIVE_ANIMATION_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/integration-api/processor-interface.h>
23 #include <dali/public-api/common/vector-wrapper.h>
24 #include <dali/public-api/signals/callback.h>
34 class RiveAnimationThread;
35 class RiveAnimationManager;
38 * @brief Rive animation manager
40 class RiveAnimationManager : public Integration::Processor
43 struct LifecycleObserver
45 virtual void RiveAnimationManagerDestroyed() = 0;
51 static RiveAnimationManager& GetInstance();
56 RiveAnimationManager();
61 ~RiveAnimationManager() override;
64 * Add a lifecycle observer
65 * @param[in] observer The object watching this one
67 void AddObserver(LifecycleObserver& observer);
70 * Remove a lifecycle observer
71 * @param[in] observer The object watching this one
73 void RemoveObserver(LifecycleObserver& observer);
76 * Get the rive animation thread.
77 * @return A raw pointer pointing to the rive animation thread.
79 RiveAnimationThread& GetRiveAnimationThread();
82 * @brief Register a callback.
84 * @param callback The callback to register
85 * @note Ownership of the callback is passed onto this class.
87 void RegisterEventCallback(CallbackBase* callback);
90 * @brief Unregister a previously registered callback
92 * @param callback The callback to unregister
94 void UnregisterEventCallback(CallbackBase* callback);
96 protected: // Implementation of Processor
98 * @copydoc Dali::Integration::Processor::Process()
100 void Process(bool postProcessor) override;
103 * @copydoc Dali::Integration::Processor::GetProcessorName()
105 std::string_view GetProcessorName() const override
107 return "RiveAnimationManager";
112 RiveAnimationManager(const RiveAnimationManager& manager) = delete;
115 RiveAnimationManager& operator=(const RiveAnimationManager& manager) = delete;
118 static std::unique_ptr<RiveAnimationManager> mInstance;
119 static std::once_flag mOnceFlag;
121 std::vector<std::unique_ptr<CallbackBase>> mEventCallbacks;
122 std::vector<LifecycleObserver*> mLifecycleObservers;
123 std::unique_ptr<RiveAnimationThread> mRiveAnimationThread;
124 bool mProcessorRegistered;
127 } // namespace Internal
129 } // namespace Extension
133 #endif // DALI_EXTENSION_INTERNAL_RIVE_ANIMATION_MANAGER_H