SOLA
Loading...
Searching...
No Matches
logical_node_info.h
1// Copyright The SOLA Contributors
2//
3// Licensed under the MIT License.
4// For details on the licensing terms, see the LICENSE file.
5// SPDX-License-Identifier: MIT
6
7#ifndef MINHTON_CORE_LOGICAL_NODE_INFO_H_
8#define MINHTON_CORE_LOGICAL_NODE_INFO_H_
9
10#include <string>
11
12#include "solanet/serializer/serialize.h"
13#include "solanet/uuid.h"
14#include "solanet/uuid_generator.h"
15
16namespace minhton
17
18{
19
24public:
25 LogicalNodeInfo() = default;
26
42 explicit LogicalNodeInfo(uint16_t fanout);
43
59 LogicalNodeInfo(uint32_t level, uint32_t number);
60
76 LogicalNodeInfo(uint32_t level, uint32_t number, uint16_t fanout);
77
79 uint32_t getLevel() const;
80
82 uint32_t getNumber() const;
83
85 std::string getString() const;
86
88 uint16_t getFanout() const;
89
91 std::string getUuid() const;
92
94 solanet::UUID getRawUuid() const;
95
97 double getHorizontalValue() const;
98
108 void setFanout(uint16_t fanout);
109
123 void setPosition(uint32_t level, uint32_t number);
124
138 void setPosition(LogicalNodeInfo other);
139
150 bool isInitialized() const;
151
161 bool isRoot() const;
162
174 bool isSameLevel(LogicalNodeInfo other) const;
175
188 bool isDeeperThan(LogicalNodeInfo other) const;
189
204
214 bool isPrioNode() const;
215
216 friend bool operator==(const minhton::LogicalNodeInfo &p1, const minhton::LogicalNodeInfo &p2);
217 friend bool operator!=(const minhton::LogicalNodeInfo &p1, const minhton::LogicalNodeInfo &p2);
218 friend bool operator<(const minhton::LogicalNodeInfo &p1, const minhton::LogicalNodeInfo &p2);
219 friend bool operator<=(const minhton::LogicalNodeInfo &p1, const minhton::LogicalNodeInfo &p2);
220 friend bool operator>(const minhton::LogicalNodeInfo &p1, const minhton::LogicalNodeInfo &p2);
221 friend bool operator>=(const minhton::LogicalNodeInfo &p1, const minhton::LogicalNodeInfo &p2);
222
223 SERIALIZE(level_, number_, fanout_, uuid_, initialized_);
224
225private:
226 uint32_t level_ = 0;
227 uint32_t number_ = 0;
228 uint16_t fanout_ = 0;
229 solanet::UUID uuid_ = solanet::generateUUID();
230 bool initialized_ = false;
231};
232
234 std::size_t operator()(const minhton::LogicalNodeInfo &l_node_info) const {
235 using std::hash;
236 using std::size_t;
237 using std::string;
238
239 std::string rep = std::to_string(l_node_info.getLevel()) + ":" +
240 std::to_string(l_node_info.getNumber()) + ":" +
241 std::to_string(l_node_info.getFanout()) +
242 (l_node_info.isInitialized() ? "init" : "uninit");
243 std::size_t res = std::hash<std::string>()(rep);
244 return res;
245 }
246};
247
248} // namespace minhton
249#endif
Definition logical_node_info.h:23
uint32_t getLevel() const
Definition logical_node_info.cpp:59
uint16_t getFanout() const
Definition logical_node_info.cpp:63
bool isInitialized() const
Definition logical_node_info.cpp:86
uint32_t getNumber() const
Definition logical_node_info.cpp:61
std::string getUuid() const
Definition logical_node_info.cpp:122
bool isSameLevel(LogicalNodeInfo other) const
Definition logical_node_info.cpp:88
bool isPrioNode() const
Definition logical_node_info.cpp:118
solanet::UUID getRawUuid() const
Definition logical_node_info.cpp:124
bool isDeeperThanOrSameLevel(LogicalNodeInfo other) const
Definition logical_node_info.cpp:108
double getHorizontalValue() const
Definition logical_node_info.cpp:126
std::string getString() const
Definition logical_node_info.cpp:54
bool isDeeperThan(LogicalNodeInfo other) const
Definition logical_node_info.cpp:98
void setFanout(uint16_t fanout)
Definition logical_node_info.cpp:65
bool isRoot() const
Definition logical_node_info.cpp:78
void setPosition(uint32_t level, uint32_t number)
Definition logical_node_info.cpp:32
Definition minhton_watchdog_ns3.cpp:24
Definition logical_node_info.h:233