GHS
Leader Election Based on GHS Minimum Spanning Tree
ghs-demo-config.h
Go to the documentation of this file.
1 
40 #ifndef DEMO_CONFIG
41 #define DEMO_CONFIG
42 
44 #define MAX_N 8
45 
47 #define MAX_ENDPOINT_SZ 256
48 
50 #define N_UNSET 0
51 
53 #define ID_UNSET -1
54 
55 #include <cstdint>
56 
58 namespace demo{
64  struct Config
65  {
67  float wait_s= 0 ;
68 
71 
74 
76  int test=0;
77 
80 
82  enum {
83  LOAD=0,
84  TEST,
86  }command=LOAD;
88 
90  bool retry_connections=false;
91 
93 
94  };
95 
102  bool cfg_is_ok(Config config);
103 
109  void read_cfg_file(const char* fname, Config* c);
110 
120  void read_cfg_stdin(Config*c);
121 
127  void read_cfg_cli(int argc, char** argv, Config* c);
128 
129 }
130 
131 #endif
MAX_N
#define MAX_N
The maximum number of agents the demo can accomodate.
Definition: ghs-demo-config.h:44
demo::Config::test
int test
A bool to determine if we should do a test-and-die routine or not.
Definition: ghs-demo-config.h:76
demo::Config::command
enum demo::Config::@0 command
A special command enumeration.
demo::cfg_is_ok
bool cfg_is_ok(Config config)
Definition: ghs-demo-inireader.cpp:184
N_UNSET
#define N_UNSET
A special value for N that means "not set yet".
Definition: ghs-demo-config.h:50
demo::Config::START
@ START
Start MST construction after specified delay.
Definition: ghs-demo-config.h:85
demo
Definition: ghs-demo-clireader.cpp:44
demo::read_cfg_file
void read_cfg_file(const char *fname, Config *c)
Definition: ghs-demo-inireader.cpp:59
demo::Config::TEST
@ TEST
run test-and-die routine
Definition: ghs-demo-config.h:84
demo::Config::my_id
int my_id
This agent's id.
Definition: ghs-demo-config.h:79
demo::Config::retry_connections
bool retry_connections
If we fail to dial up an agent, should we retry later (true) or drop the message (false)
Definition: ghs-demo-config.h:90
demo::Config
A struct that holds the union of all configuration variables.
Definition: ghs-demo-config.h:64
demo::read_cfg_stdin
void read_cfg_stdin(Config *c)
Definition: ghs-demo-inireader.cpp:211
demo::Config::endpoints
char endpoints[MAX_N][MAX_ENDPOINT_SZ]
The endpoint for each agent, as read from the config.
Definition: ghs-demo-config.h:73
ID_UNSET
#define ID_UNSET
A special value for an ID that means "not set yet".
Definition: ghs-demo-config.h:53
demo::Config::LOAD
@ LOAD
Load config and do nothing else.
Definition: ghs-demo-config.h:83
demo::Config::n_agents
int n_agents
The number of agents currently loaded.
Definition: ghs-demo-config.h:70
demo::read_cfg_cli
void read_cfg_cli(int argc, char **argv, Config *config)
Definition: ghs-demo-clireader.cpp:94
MAX_ENDPOINT_SZ
#define MAX_ENDPOINT_SZ
The max strlen() of the endpoint.
Definition: ghs-demo-config.h:47
demo::Config::wait_s
float wait_s
The time to wait before starting the main algorithm.
Definition: ghs-demo-config.h:67