• 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 #ifndef MAPLE_UTIL_INCLUDE_BASE_GRAPH_NODE_H
16 #define MAPLE_UTIL_INCLUDE_BASE_GRAPH_NODE_H
17 #include "types_def.h"
18 #include "mempool_allocator.h"
19 namespace maple {
20 
21 class BaseGraphNode {
22 public:
23     virtual void GetOutNodes(std::vector<BaseGraphNode *> &outNodes) = 0;
24     virtual void GetOutNodes(std::vector<BaseGraphNode *> &outNodes) const = 0;
25     virtual void GetInNodes(std::vector<BaseGraphNode *> &outNodes) = 0;
26     virtual void GetInNodes(std::vector<BaseGraphNode *> &outNodes) const = 0;
27     virtual const std::string GetIdentity() = 0;
28     virtual uint32 GetID() const = 0;
29 };
30 
31 // BaseGraphNode needs to be the base class of T
32 template <typename T, std::enable_if_t<std::is_base_of<BaseGraphNode, T>::value, bool> = true>
ConvertToVectorOfBasePtr(const MapleVector<T * > & originVec,MapleVector<BaseGraphNode * > & targetVec)33 void ConvertToVectorOfBasePtr(const MapleVector<T *> &originVec, MapleVector<BaseGraphNode *> &targetVec)
34 {
35     for (auto &item : originVec) {
36         targetVec.emplace_back(item);
37     }
38 }
39 }  // namespace maple
40 #endif /* MAPLE_UTIL_INCLUDE_BASE_GRAPH_NODE_H */
41