MCPcopy Create free account
hub / github.com/Icinga/icinga2 / Edge

Class Edge

lib/base/dependencygraph.hpp:37–86  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

35 * It allows to traverse the graph in both directions, i.e. from parent to child and vice versa.
36 */
37 struct Edge
38 {
39 ConfigObject* parent; // The parent object of the child one.
40 ConfigObject* child; // The dependent object of the parent.
41 // Counter for the number of parent <-> child edges to allow duplicates.
42 int count;
43
44 Edge(ConfigObject* parent, ConfigObject* child, int count = 1): parent(parent), child(child), count(count)
45 {
46 }
47
48 struct Hash
49 {
50 /**
51 * Generates a unique hash of the given Edge object.
52 *
53 * Note, the hash value is generated only by combining the hash values of the parent and child pointers.
54 *
55 * @param edge The Edge object to be hashed.
56 *
57 * @return size_t The resulting hash value of the given object.
58 */
59 size_t operator()(const Edge& edge) const
60 {
61 size_t seed = 0;
62 boost::hash_combine(seed, edge.parent);
63 boost::hash_combine(seed, edge.child);
64
65 return seed;
66 }
67 };
68
69 struct Equal
70 {
71 /**
72 * Compares whether the two Edge objects contain the same parent and child pointers.
73 *
74 * Note, the member property count is not taken into account for equality checks.
75 *
76 * @param a The first Edge object to compare.
77 * @param b The second Edge object to compare.
78 *
79 * @return bool Returns true if the two objects are equal, false otherwise.
80 */
81 bool operator()(const Edge& a, const Edge& b) const
82 {
83 return a.parent == b.parent && a.child == b.child;
84 }
85 };
86 };
87
88 using DependencyMap = boost::multi_index_container<
89 Edge, // The value type we want to sore in the container.

Callers 2

AddDependencyMethod · 0.85
RemoveDependencyMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected