• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022-2023 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 /**
17  * @addtogroup RenderNodeDisplay
18  * @{
19  *
20  * @brief Display render nodes.
21  */
22 
23 /**
24  * @file rs_modifier_manager_map.h
25  *
26  * @brief Defines the properties and methods for RSModifierManagerMap class.
27  */
28 
29 #ifndef RENDER_SERVICE_CLIENT_CORE_MODIFIER_RS_MODIFIER_MANAGER_MAP_H
30 #define RENDER_SERVICE_CLIENT_CORE_MODIFIER_RS_MODIFIER_MANAGER_MAP_H
31 
32 #include <mutex>
33 #include <unordered_map>
34 #include <memory>
35 
36 #include "common/rs_macros.h"
37 
38 namespace OHOS {
39 namespace Rosen {
40 
41 /**
42  * @class RSModifierManagerMap
43  *
44  * @brief The class for managing RSModifierManager instances.
45  */
46 class RSModifierManager;
47 
48 /**
49  * @class RSModifierManagerMap
50  *
51  * @brief The class for managing RSModifierManager instances.
52  */
53 class RSC_EXPORT RSModifierManagerMap final {
54 public:
55     /**
56      * @brief Destructor for RSModifierManagerMap.
57      */
58     ~RSModifierManagerMap() = default;
59 
60     /**
61      * @brief Provides a singleton instance of the RSModifierManagerMap.
62      *
63      * @return A constant reference to the singleton instance of RSModifierManagerMap.
64      */
65     static std::shared_ptr<RSModifierManagerMap>& Instance();
66 
67     /**
68      * @brief Gets the RSModifierManager associated with the given ID.
69      *
70      * @param id The unique identifier for the RSModifierManager.
71      * @return A shared pointer to the RSModifierManager associated with the given ID.
72      */
73     const std::shared_ptr<RSModifierManager>& GetModifierManager(const int32_t id);
74 
75 private:
76     RSModifierManagerMap() = default;
77     RSModifierManagerMap(const RSModifierManagerMap&) = delete;
78     RSModifierManagerMap(const RSModifierManagerMap&&) = delete;
79     RSModifierManagerMap& operator=(const RSModifierManagerMap&) = delete;
80     RSModifierManagerMap& operator=(const RSModifierManagerMap&&) = delete;
81 
82     std::mutex mutex_;
83     std::unordered_map<int32_t, std::shared_ptr<RSModifierManager>> managerMap_;
84     static std::shared_ptr<RSModifierManagerMap> instance_;
85 };
86 } // namespace Rosen
87 } // namespace OHOS
88 
89 /** @} */
90 #endif // RENDER_SERVICE_CLIENT_CORE_MODIFIER_RS_MODIFIER_MANAGER_MAP_H
91