FREEDM DGI
CGlobalConfiguration.hpp
Go to the documentation of this file.
1 
32 #ifndef CGLOBALCONFIGURATION_HPP
33 #define CGLOBALCONFIGURATION_HPP
34 
35 #include <climits>
36 #include <string>
37 #include <vector>
38 
39 #include <boost/date_time/posix_time/posix_time.hpp>
40 #include <boost/asio/io_service.hpp>
41 
42 namespace freedm {
43 namespace broker {
44 
46 class CGlobalConfiguration : private boost::noncopyable
47 {
48  public:
51  {
52  static CGlobalConfiguration instance;
53  return instance;
54  }
56  void SetHostname(std::string h) { m_hostname = h; };
58  void SetListenPort(std::string p) { m_port = p; };
60  void SetUUID(std::string u) { m_uuid = u; };
62  void SetListenAddress(std::string a) { m_address = a; };
64  void SetClockSkew(boost::posix_time::time_duration t)
65  { m_clockskew = t; };
67  void SetFactoryPort(unsigned short port) { m_factory_port = port; }
69  void SetDevicesEndpoint(std::string e) { m_devicesEndpoint = e; };
71  void SetAdapterConfigPath(std::string ac) { m_adapterConfigPath = ac; };
73  void SetDeviceConfigPath(std::string p) { m_deviceConfigPath = p; }
75  void SetTopologyConfigPath(std::string p) { m_topologyConfigPath = p; }
77  void SetMigrationStep(float v) { m_migrationStep = v; }
79  void SetMaliciousFlag(bool flag) { m_malicious = flag; }
81  void SetInvariantCheck(bool flag) { m_invariant = flag; }
83  void SetMQTTId(std::string id) { m_mqtt_id = id; }
85  void SetMQTTAddress(std::string address) { m_mqtt_address = address; }
87  void SetMQTTSubscriptions(std::vector<std::string> subs) { m_mqtt_subscriptions = subs; }
89  std::string GetHostname() const { return m_hostname; };
91  std::string GetListenPort() const { return m_port; };
93  std::string GetUUID() const { return m_uuid; };
95  std::string GetListenAddress() const { return m_address; };
97  boost::posix_time::time_duration GetClockSkew() const
98  { return m_clockskew; };
100  unsigned short GetFactoryPort() const { return m_factory_port; }
102  std::string GetDevicesEndpoint() const { return m_devicesEndpoint; };
104  std::string GetAdapterConfigPath() const { return m_adapterConfigPath; };
106  std::string GetDeviceConfigPath() const { return m_deviceConfigPath; }
108  static const short MAX_PACKET_SIZE = SHRT_MAX;
110  std::string GetTopologyConfigPath() const { return m_topologyConfigPath; }
112  float GetMigrationStep() const { return m_migrationStep; }
114  bool GetMaliciousFlag() const { return m_malicious; }
116  bool GetInvariantCheck() const { return m_invariant; }
118  std::string GetMQTTId() const { return m_mqtt_id; }
120  std::string GetMQTTAddress() const { return m_mqtt_address; }
122  std::vector<std::string> GetMQTTSubscriptions() const { return m_mqtt_subscriptions; }
123  private:
124  std::string m_hostname;
125  std::string m_port;
126  std::string m_uuid;
127  std::string m_address;
128  boost::posix_time::time_duration m_clockskew;
129  unsigned short m_factory_port;
130  std::string m_devicesEndpoint;
131  std::string m_adapterConfigPath;
132  std::string m_deviceConfigPath;
133  std::string m_topologyConfigPath;
135  bool m_malicious; // Flag to indicate whether load balance is malicious
136  bool m_invariant; // Flag that indicates whether to check the invariant
137  std::string m_mqtt_id;
138  std::string m_mqtt_address;
139  std::vector<std::string> m_mqtt_subscriptions;
140 };
141 
142 } // namespace broker
143 } // namespace freedm
144 
145 #endif
std::string m_hostname
Definition: CGlobalConfiguration.hpp:124
std::string m_adapterConfigPath
Socket endpoint address for devices.
Definition: CGlobalConfiguration.hpp:131
void SetListenAddress(std::string a)
Set the address to on.
Definition: CGlobalConfiguration.hpp:62
void SetInvariantCheck(bool flag)
Set the invariant check flag.
Definition: CGlobalConfiguration.hpp:81
static CGlobalConfiguration & Instance()
Returns the singleton instance of the global configuration.
Definition: CGlobalConfiguration.hpp:50
void SetDeviceConfigPath(std::string p)
Set the path to the device class XML specification file.
Definition: CGlobalConfiguration.hpp:73
void SetMaliciousFlag(bool flag)
Set the malicious load balance flag.
Definition: CGlobalConfiguration.hpp:79
void SetMQTTSubscriptions(std::vector< std::string > subs)
Set the MQTT subscriptions.
Definition: CGlobalConfiguration.hpp:87
std::string m_mqtt_id
Definition: CGlobalConfiguration.hpp:137
A singleton class which tracks commonly used configuration options.
Definition: CGlobalConfiguration.hpp:46
std::string GetDevicesEndpoint() const
Get the socket endpoint address.
Definition: CGlobalConfiguration.hpp:102
std::string GetUUID() const
Get the UUID.
Definition: CGlobalConfiguration.hpp:93
void SetDevicesEndpoint(std::string e)
Set the socket endpoint address.
Definition: CGlobalConfiguration.hpp:69
float GetMigrationStep() const
Get the size of a load balance migration.
Definition: CGlobalConfiguration.hpp:112
void SetFactoryPort(unsigned short port)
Set the plug-and-play port number.
Definition: CGlobalConfiguration.hpp:67
unsigned short GetFactoryPort() const
Get the plug-and-play port number.
Definition: CGlobalConfiguration.hpp:100
std::string m_address
The node uuid.
Definition: CGlobalConfiguration.hpp:127
void SetMQTTId(std::string id)
Set the MQTT client identifier.
Definition: CGlobalConfiguration.hpp:83
bool m_invariant
Definition: CGlobalConfiguration.hpp:136
std::string m_topologyConfigPath
Path to the device class config.
Definition: CGlobalConfiguration.hpp:133
std::string GetListenPort() const
Get the port.
Definition: CGlobalConfiguration.hpp:91
void SetTopologyConfigPath(std::string p)
Set the path to the topology config file.
Definition: CGlobalConfiguration.hpp:75
std::string m_deviceConfigPath
Path to the adapter configuration.
Definition: CGlobalConfiguration.hpp:132
std::string GetMQTTAddress() const
Get the MQTT broker address.
Definition: CGlobalConfiguration.hpp:120
boost::posix_time::time_duration m_clockskew
The listening address.
Definition: CGlobalConfiguration.hpp:128
void SetAdapterConfigPath(std::string ac)
Set the path to the adapter configuration file.
Definition: CGlobalConfiguration.hpp:71
void SetListenPort(std::string p)
Set the port.
Definition: CGlobalConfiguration.hpp:58
std::string m_uuid
Port number.
Definition: CGlobalConfiguration.hpp:126
std::string GetMQTTId() const
Get the MQTT client identifier.
Definition: CGlobalConfiguration.hpp:118
boost::posix_time::time_duration GetClockSkew() const
Get the Skew of the local clock.
Definition: CGlobalConfiguration.hpp:97
std::string GetAdapterConfigPath() const
Get the path to the adapter configuration file.
Definition: CGlobalConfiguration.hpp:104
void SetUUID(std::string u)
Set the uuid.
Definition: CGlobalConfiguration.hpp:60
bool GetMaliciousFlag() const
Get the malicious load balance flag.
Definition: CGlobalConfiguration.hpp:114
std::string GetHostname() const
Get the hostname.
Definition: CGlobalConfiguration.hpp:89
static const short MAX_PACKET_SIZE
Intentionally signed. UINT16_MAX is too big for a UDP datagram, anyway.
Definition: CGlobalConfiguration.hpp:108
std::vector< std::string > m_mqtt_subscriptions
Address of the MQTT broker.
Definition: CGlobalConfiguration.hpp:139
std::string GetListenAddress() const
Get the address.
Definition: CGlobalConfiguration.hpp:95
bool m_malicious
Size of a load balance migration.
Definition: CGlobalConfiguration.hpp:135
void SetHostname(std::string h)
Set the hostname.
Definition: CGlobalConfiguration.hpp:56
unsigned short m_factory_port
The skew of the clock.
Definition: CGlobalConfiguration.hpp:129
void SetMQTTAddress(std::string address)
Set the MQTT broker address.
Definition: CGlobalConfiguration.hpp:85
std::string m_devicesEndpoint
Port number for adapter factory.
Definition: CGlobalConfiguration.hpp:130
std::vector< std::string > GetMQTTSubscriptions() const
Get the MQTT subscriptions.
Definition: CGlobalConfiguration.hpp:122
float m_migrationStep
Path to the topology config.
Definition: CGlobalConfiguration.hpp:134
General FREEDM Namespace.
Definition: CBroker.cpp:53
std::string m_mqtt_address
Identifier of the MQTT client.
Definition: CGlobalConfiguration.hpp:138
std::string m_port
Node hostname.
Definition: CGlobalConfiguration.hpp:125
void SetClockSkew(boost::posix_time::time_duration t)
Set the clock skew.
Definition: CGlobalConfiguration.hpp:64
std::string GetDeviceConfigPath() const
Get the path to the device class XML specification file.
Definition: CGlobalConfiguration.hpp:106
void SetMigrationStep(float v)
Set the size of a load balance migration.
Definition: CGlobalConfiguration.hpp:77
bool GetInvariantCheck() const
Get the invariant check flag.
Definition: CGlobalConfiguration.hpp:116
std::string GetTopologyConfigPath() const
Path to the topology specification file.
Definition: CGlobalConfiguration.hpp:110