• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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     bool IsDAG();
37 private:
38     UtdGraph();
39     ~UtdGraph();
40     UtdGraph(const UtdGraph &obj) = delete;
41     UtdGraph &operator=(const UtdGraph &obj) = delete;
42     int32_t GetIndex(const std::string &node);
43     void AddEdge(const std::string &startNode, const std::string &endNode);
44     mutable std::shared_mutex graphMutex_;
45     Graph *graph_ = nullptr;
46     std::map<std::string, uint32_t> typeIdIndex_;
47 };
48 } // namespace UDMF
49 } // namespace OHOS
50 #endif // UDMF_UTD_GRAPH_H
51