• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 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 #ifndef FOUNDATION_ACE_FRAMEWORKS_CORE_COMMON_FORM_MANAGER_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMMON_FORM_MANAGER_H
18 
19 #include <mutex>
20 #include <unordered_map>
21 
22 #include "base/utils/macros.h"
23 #include "base/utils/noncopyable.h"
24 #include "base/utils/singleton.h"
25 #include "core/components/form/resource/form_utils.h"
26 #include "core/components/form/sub_container.h"
27 
28 namespace OHOS::Ace {
29 
30 class ACE_EXPORT FormManager final : public Singleton<FormManager> {
31     DECLARE_SINGLETON(FormManager);
32 
33 public:
34     void AddSubContainer(int64_t formId, const RefPtr<SubContainer>& subContainer);
35     void RemoveSubContainer(int64_t formId);
36     RefPtr<SubContainer> GetSubContainer(int64_t formId);
37     void SetFormUtils(const std::shared_ptr<FormUtils>& formUtils);
38     std::shared_ptr<FormUtils> GetFormUtils();
39 
40 private:
41     std::mutex mutex_;
42     std::unordered_map<int64_t, RefPtr<SubContainer>> subContainerMap_;
43     std::mutex nonmatchedContainerMutex_;
44     std::unordered_map<std::string, RefPtr<SubContainer>> nonmatchedContainerMap_;
45     std::mutex formUtilsMutex_;
46     std::shared_ptr<FormUtils> formUtils_;
47 };
48 
49 } // namespace OHOS::Ace
50 
51 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMMON_FORM_MANAGER_H
52