1 /*
2  * Copyright (c) 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 #ifndef UDMF_UTD_GRAPH_H
17 #define UDMF_UTD_GRAPH_H
18 
19 #include <vector>
20 #include <map>
21 #include <stack>
22 #include <string>
23 #include <shared_mutex>
24 #include "graph.h"
25 #include "utd_common.h"
26 #include "preset_type_descriptors.h"
27 
28 namespace OHOS {
29 namespace UDMF {
30 class UtdGraph {
31 public:
32     static UtdGraph &GetInstance();
33     bool IsValidType(const std::string &node);
34     void InitUtdGraph(const std::vector<TypeDescriptorCfg> &descriptorCfgs);
35     bool IsLowerLevelType(const std::string &lowerLevelType, const std::string &heigitLevelType);
36     std::unique_ptr<Graph> ConstructNewGraph(const std::vector<TypeDescriptorCfg> &descriptorCfgs);
37     void Update(std::unique_ptr<Graph> graph);
38 private:
39     UtdGraph();
40     ~UtdGraph();
41     UtdGraph(const UtdGraph &obj) = delete;
42     UtdGraph &operator=(const UtdGraph &obj) = delete;
43     std::mutex graphMutex_;
44     std::unique_ptr<Graph> graph_;
45 };
46 } // namespace UDMF
47 } // namespace OHOS
48 #endif // UDMF_UTD_GRAPH_H
49