SOLA
Loading...
Searching...
No Matches
Public Member Functions | Friends | List of all members
minhton::LogicalNodeInfo Class Reference

#include <logical_node_info.h>

Public Member Functions

 LogicalNodeInfo (uint16_t fanout)
 0:0 is always a valid position, therefore we can use setFanout to check if the fanout is valid
 
 LogicalNodeInfo (uint32_t level, uint32_t number)
 
 LogicalNodeInfo (uint32_t level, uint32_t number, uint16_t fanout)
 
uint32_t getLevel () const
 
uint32_t getNumber () const
 
std::string getString () const
 
uint16_t getFanout () const
 
std::string getUuid () const
 
solanet::UUID getRawUuid () const
 
double getHorizontalValue () const
 
void setFanout (uint16_t fanout)
 
void setPosition (uint32_t level, uint32_t number)
 
void setPosition (LogicalNodeInfo other)
 
bool isInitialized () const
 
bool isRoot () const
 
bool isSameLevel (LogicalNodeInfo other) const
 
bool isDeeperThan (LogicalNodeInfo other) const
 
bool isDeeperThanOrSameLevel (LogicalNodeInfo other) const
 
bool isPrioNode () const
 
 SERIALIZE (level_, number_, fanout_, uuid_, initialized_)
 

Friends

bool operator== (const minhton::LogicalNodeInfo &p1, const minhton::LogicalNodeInfo &p2)
 
bool operator!= (const minhton::LogicalNodeInfo &p1, const minhton::LogicalNodeInfo &p2)
 
bool operator< (const minhton::LogicalNodeInfo &p1, const minhton::LogicalNodeInfo &p2)
 
bool operator<= (const minhton::LogicalNodeInfo &p1, const minhton::LogicalNodeInfo &p2)
 
bool operator> (const minhton::LogicalNodeInfo &p1, const minhton::LogicalNodeInfo &p2)
 
bool operator>= (const minhton::LogicalNodeInfo &p1, const minhton::LogicalNodeInfo &p2)
 

Detailed Description

LogicalNodeInfo represents the position of a peer within the p2p network. Each peer has a unique position (level:number) in the range of 0..(m^level)-1

Constructor & Destructor Documentation

◆ LogicalNodeInfo() [1/3]

minhton::LogicalNodeInfo::LogicalNodeInfo ( uint16_t  fanout)
explicit

0:0 is always a valid position, therefore we can use setFanout to check if the fanout is valid

Creates a LogicalNodeInfo object without a given position. It's optional to give a fanout. As default the k_FANOUT_DEFAULT value gets set. Level and Number are being set as 0. This object is set as not initialized. There is no possibility of initializing it. This constructor is there to represent a non-existing peer.

Typical usage:

LogicalNodeInfo l_node_info(3);
Definition logical_node_info.h:23
Parameters
fanoutmaximum number of children a node can have
Returns
nothing on success, otherwise throws std::invalid_argument in case of an invalid fanout

◆ LogicalNodeInfo() [2/3]

minhton::LogicalNodeInfo::LogicalNodeInfo ( uint32_t  p_level,
uint32_t  p_number 
)

Creates a LogicalNodeInfo object with a given position but without a fanout. Directly after the fanout is known, setFanout has to be called to set the fanout. Otherwise the fanout stays set as 0 and an invalid position might not get recognized.

Typical usage:

LogicalNodeInfo l_node_info(1, 0, true);
Parameters
levellevel in the tree, root has level 0
numbernumber in the tree, the leftmost node on the level has number 0
Returns
nothing

The fanout isn't valid, therefore setPosition will always throw an exception. When setFanout is executed afterwards (which must happen), the position will get verified this way. Therefore we can set the position directly without setPosition

◆ LogicalNodeInfo() [3/3]

minhton::LogicalNodeInfo::LogicalNodeInfo ( uint32_t  p_level,
uint32_t  p_number,
uint16_t  p_fanout 
)

Creates a LogicalNodeInfo object with a given position and fanout. It gets set as initialized. It gets verified if the position with the given fanout is valid.

Typical usage:

LogicalNodeInfo l_node_info(1, 1, 2);
Parameters
levellevel in the tree, root has level 0
numbernumber in the tree, the leftmost node on the level has number 0
fanoutmaximum number of children a node can have
Returns
nothing on success, otherwise throws std::invalid_argument in case of an invalid level:number or fanout

The validity of the fanout will get checked in setPosition. There is no need to call setFanout.

Member Function Documentation

◆ getFanout()

uint16_t minhton::LogicalNodeInfo::getFanout ( ) const
Returns
the fanout of this MINHTON tree

◆ getHorizontalValue()

double minhton::LogicalNodeInfo::getHorizontalValue ( ) const
Returns
the horizontal value defined by the TreeMapper of this peer

◆ getLevel()

uint32_t minhton::LogicalNodeInfo::getLevel ( ) const
Returns
the level of this peer within MINHTON tree

◆ getNumber()

uint32_t minhton::LogicalNodeInfo::getNumber ( ) const
Returns
the number of this peer within MINHTON tree

◆ getRawUuid()

solanet::UUID minhton::LogicalNodeInfo::getRawUuid ( ) const
Returns
the uuid of this peer

◆ getString()

std::string minhton::LogicalNodeInfo::getString ( ) const
Returns
a readable representation of information about this peer

◆ getUuid()

std::string minhton::LogicalNodeInfo::getUuid ( ) const
Returns
the uuid string of this peer

◆ isDeeperThan()

bool minhton::LogicalNodeInfo::isDeeperThan ( LogicalNodeInfo  other) const

Checks if another peer has a deeper/ higher (>) level. E.g. a peer with level 1 is deeper/higher than a peer (root) on level 0

Typical usage:

isDeeperThan(anotherPeer);
bool isDeeperThan(LogicalNodeInfo other) const
Definition logical_node_info.cpp:98
Parameters
otherinstance of a peer which is compared to.
Returns
true if same level, otherwise false.

◆ isDeeperThanOrSameLevel()

bool minhton::LogicalNodeInfo::isDeeperThanOrSameLevel ( LogicalNodeInfo  other) const

Checks if another peer has is on the same or on a deeper/ higher (>=) level. E.g. a peer on level 2 is deeper/higher or on the same level than a peer (root) on level 0 The same peer on level 2 is also on the same level as another peer on level 2

Typical usage:

bool isDeeperThanOrSameLevel(LogicalNodeInfo other) const
Definition logical_node_info.cpp:108
Parameters
otherinstance of a peer which is compared to.
Returns
true if same level, otherwise false.

◆ isInitialized()

bool minhton::LogicalNodeInfo::isInitialized ( ) const

Returns the current state of the peer if the peer is proper initialized. It depends on the constructor call.

Typical usage:

bool isInitialized() const
Definition logical_node_info.cpp:86
Returns
true if the peer has proper level:number:fanout

◆ isPrioNode()

bool minhton::LogicalNodeInfo::isPrioNode ( ) const

Checks if the current peer with its level:number is part of the prio-node set

Typical usage:

bool isPrioNode() const
Definition logical_node_info.cpp:118
Returns
true if peer is a prio-node, otherwise false.

◆ isRoot()

bool minhton::LogicalNodeInfo::isRoot ( ) const

Checks if the current peer is the root peer, in fact level = 0 and number = 0

Typical usage:

bool isRoot() const
Definition logical_node_info.cpp:78
Returns
true if peer root, otherwise false.

◆ isSameLevel()

bool minhton::LogicalNodeInfo::isSameLevel ( LogicalNodeInfo  other) const

Checks if another peer has the same level

Typical usage:

isSameLevel(anotherPeer);
bool isSameLevel(LogicalNodeInfo other) const
Definition logical_node_info.cpp:88
Parameters
otherinstance of a peer which is compared to.
Returns
true if same level, otherwise false.

◆ setFanout()

void minhton::LogicalNodeInfo::setFanout ( uint16_t  fanout)

Sets the fanout of this peer

Typical usage:

void setFanout(uint16_t fanout)
Definition logical_node_info.cpp:65
Parameters
fanout

◆ setPosition() [1/2]

void minhton::LogicalNodeInfo::setPosition ( LogicalNodeInfo  other)

Sets the position of peer based on the passed peer. All information get copied, also fanout and initialization status.

Typical usage:

setPosition(other);
void setPosition(uint32_t level, uint32_t number)
Definition logical_node_info.cpp:32
Parameters
otherpeer with the new level, number, fanout and initialized
Returns
nothing on succes, otherwise throws std::invalid_argument in case of an invalid level:number

◆ setPosition() [2/2]

void minhton::LogicalNodeInfo::setPosition ( uint32_t  level,
uint32_t  number 
)

Sets the position of a peer depending on the previous set fanout

Typical usage:

Parameters
levelfor the new level
numberfor the new number
Returns
nothing on success, otherwise throws std::invalid_argument in case of an invalid level:number

The documentation for this class was generated from the following files: