Open Model Railroad Network (OpenMRN)
Loading...
Searching...
No Matches
utils/NetworkState.hxx
Go to the documentation of this file.
1
27#ifndef _UTILS_NETWORKSTATE_HXX_
28#define _UTILS_NETWORKSTATE_HXX_
29
30#include <functional>
31
33
36{
37public:
38 enum State
39 {
40 VALID = 0,
41 INVALID = 1,
42 UNKNOWN = 3,
43 };
44
46 virtual ~NetworkState()
47 {
48 }
49
53 virtual void set_callback(std::function<void()> cb) = 0;
54
58 virtual void toggle(Notifiable *done) = 0;
59
64 virtual void set_state(bool state, Notifiable *done) = 0;
65
68 virtual State get_state() = 0;
69
72 virtual bool is_state_known() = 0;
73
77 virtual void initiate_query(BarrierNotifiable *done) = 0;
78
80 virtual void reset() = 0;
81};
82
83#endif // _UTILS_NETWORKSTATE_HXX_
A BarrierNotifiable allows to create a number of child Notifiable and wait for all of them to finish.
"Abstract" interface for a binary network state.
virtual ~NetworkState()
Destructor.
virtual bool is_state_known()=0
Get an indication as to if the state is known.
virtual State get_state()=0
Get the current state.
virtual void toggle(Notifiable *done)=0
Toggle the state.
@ INVALID
state is "invalid"
@ UNKNOWN
state is "unknown"
@ VALID
state is "valid"
virtual void initiate_query(BarrierNotifiable *done)=0
Queries and acquires the current state of the bit.
virtual void reset()=0
Reset the network state to unknown.
virtual void set_state(bool state, Notifiable *done)=0
Set the state.
virtual void set_callback(std::function< void()> cb)=0
Set the change notification callback.
An object that can schedule itself on an executor to run.