blob: 38f2bb33be4a9b64bb97a35a6c1f00eeabbe671b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
// Copyright (C) 2018 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0
//
#ifndef NODE_HPP
#define NODE_HPP
#include <vector>
#include <utility>
#include <memory>
#include "util/range.hpp"
#include "util/map_range.hpp"
#include "edge.hpp"
#include "handle.hpp"
#include "metadata.hpp"
namespace ade
{
class Graph;
class Edge;
class Node;
using NodeHandle = Handle<Node>;
class Node final : public std::enable_shared_from_this<Node>
{
public:
struct HandleMapper final
{
EdgeHandle operator()(Edge* obj) const;
};
struct InEdgeMapper final
{
NodeHandle operator()(const EdgeHandle& handle) const;
};
struct OutEdgeMapper final
{
NodeHandle operator()(const EdgeHandle& handle) const;
};
using EdgeSet = std::vector<Edge*>;
using EdgeSetRange = util::MapRange<util::IterRange<EdgeSet::iterator>, HandleMapper>;
using EdgeSetCRange = util::MapRange<util::IterRange<EdgeSet::const_iterator>, HandleMapper>;
using InNodeSetRange = util::MapRange<EdgeSetRange, InEdgeMapper>;
using InNodeSetCRange = util::MapRange<EdgeSetCRange, InEdgeMapper>;
using OutNodeSetRange = util::MapRange<EdgeSetRange, OutEdgeMapper>;
using OutNodeSetCRange = util::MapRange<EdgeSetCRange, OutEdgeMapper>;
EdgeSetRange inEdges();
EdgeSetCRange inEdges() const;
EdgeSetRange outEdges();
EdgeSetCRange outEdges() const;
InNodeSetRange inNodes();
InNodeSetCRange inNodes() const;
OutNodeSetRange outNodes();
OutNodeSetCRange outNodes() const;
private:
friend class Graph;
friend class Edge;
Node(Graph* parent);
~Node();
Node(const Node&) = delete;
Node& operator=(const Node&) = delete;
Graph* getParent() const;
void unlink();
void addInEdge(Edge* edge);
void removeInEdge(Edge* edge);
void addOutEdge(Edge* edge);
void removeOutEdge(Edge* edge);
Graph* m_parent = nullptr;
EdgeSet m_inEdges;
EdgeSet m_outEdges;
};
}
#endif // NODE_HPP
|