[dali_2.3.20] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / visuals / animated-vector-image / vector-animation-manager.h
1 #ifndef DALI_TOOLKIT_INTERNAL_VECTOR_ANIMATION_MANAGER_H
2 #define DALI_TOOLKIT_INTERNAL_VECTOR_ANIMATION_MANAGER_H
3
4 /*
5  * Copyright (c) 2023 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 <dali/integration-api/processor-interface.h>
23 #include <dali/public-api/common/vector-wrapper.h>
24 #include <dali/public-api/signals/callback.h>
25 #include <memory>
26
27 // INTERNAL INCLUDES
28
29 namespace Dali
30 {
31 namespace Toolkit
32 {
33 namespace Internal
34 {
35 class VectorAnimationThread;
36
37 /**
38  * @brief Vector animation manager
39  */
40 class VectorAnimationManager : public Integration::Processor
41 {
42 public:
43   struct LifecycleObserver
44   {
45     virtual void VectorAnimationManagerDestroyed() = 0;
46   };
47
48   /**
49    * @brief Constructor.
50    */
51   VectorAnimationManager();
52
53   /**
54    * @brief Destructor.
55    */
56   ~VectorAnimationManager() override;
57
58   /**
59    * Add a lifecycle observer
60    * @param[in] observer The object watching this one
61    */
62   void AddObserver(LifecycleObserver& observer);
63
64   /**
65    * Remove a lifecycle observer
66    * @param[in] observer The object watching this one
67    */
68   void RemoveObserver(LifecycleObserver& observer);
69
70   /**
71    * Get the vector animation thread.
72    * @return A raw pointer pointing to the vector animation thread.
73    */
74   VectorAnimationThread& GetVectorAnimationThread();
75
76   /**
77    * @brief Register a callback.
78    *
79    * @param callback The callback to register
80    * @note Ownership of the callback is passed onto this class.
81    */
82   void RegisterEventCallback(CallbackBase* callback);
83
84   /**
85    * @brief Unregister a previously registered callback
86    *
87    * @param callback The callback to unregister
88    */
89   void UnregisterEventCallback(CallbackBase* callback);
90
91 protected: // Implementation of Processor
92   /**
93    * @copydoc Dali::Integration::Processor::Process()
94    */
95   void Process(bool postProcessor) override;
96
97   /**
98    * @copydoc Dali::Integration::Processor::GetProcessorName()
99    */
100   std::string_view GetProcessorName() const override
101   {
102     return "VectorAnimationManager";
103   }
104
105 private:
106   // Undefined
107   VectorAnimationManager(const VectorAnimationManager& manager) = delete;
108
109   // Undefined
110   VectorAnimationManager& operator=(const VectorAnimationManager& manager) = delete;
111
112 private:
113   std::vector<std::unique_ptr<CallbackBase>> mEventCallbacks;
114   std::vector<LifecycleObserver*>            mLifecycleObservers;
115   std::unique_ptr<VectorAnimationThread>     mVectorAnimationThread;
116   bool                                       mProcessorRegistered;
117 };
118
119 } // namespace Internal
120
121 } // namespace Toolkit
122
123 } // namespace Dali
124
125 #endif // DALI_TOOLKIT_INTERNAL_VECTOR_ANIMATION_MANAGER_H