OpenTwin 0.1
OpenTwin
 
Loading...
Searching...
No Matches
Configuration.h
Go to the documentation of this file.
1#pragma once
2
3// Project header
5
6// OpenTwin header
9
10// C++ header
11#include <string>
12#include <list>
13
15#define LDS_CFG Configuration::instance()
16
18public:
19 static Configuration& instance(void);
20
24 virtual void addToJsonObject(ot::JsonValue& _object, ot::JsonAllocator& _allocator) const override;
25
29 virtual void setFromJsonObject(const ot::ConstJsonObject& _object) override;
30
34 int importFromEnvironment(void);
35
37 bool supportsService(const std::string& _serviceName) const;
38
39 void setSupportedServices(const std::list<ServiceInformation>& _services) { m_supportedServices = _services; };
40 const std::list<ServiceInformation>& supportedServices(void) const { return m_supportedServices; };
41
42 void setLauncherPath(const std::string& _launcherPath) { m_launcherPath = _launcherPath; };
43 const std::string launcherPath(void) const { return m_launcherPath; };
44
45 void setServicesLibraryPath(const std::string& _path) { m_servicesLibraryPath = _path; };
46 const std::string& servicesLibraryPath(void) const { return m_servicesLibraryPath; };
47
48 void setDefaultMaxCrashRestarts(unsigned int _restarts) { m_defaultMaxCrashRestarts = _restarts; };
49 unsigned int defaultMaxCrashRestarts(void) const { return m_defaultMaxCrashRestarts; };
50
51 void setDefaultMaxStartupRestarts(unsigned int _restarts) { m_defaultMaxStartupRestarts = _restarts; };
52 unsigned int defaultMaxStartupRestarts(void) const { return m_defaultMaxStartupRestarts; };
53
54private:
55 bool m_configurationImported;
56 std::list<ServiceInformation> m_supportedServices;
57 std::string m_launcherPath;
58 std::string m_servicesLibraryPath;
59 unsigned int m_defaultMaxCrashRestarts;
60 unsigned int m_defaultMaxStartupRestarts;
61
63 virtual ~Configuration();
65 Configuration& operator = (Configuration&) = delete;
66};
This file contains defines that may be used simplyfy class creation.
Definition Configuration.h:17
virtual ~Configuration()
Definition Configuration.cpp:176
const std::list< ServiceInformation > & supportedServices(void) const
Definition Configuration.h:40
static Configuration & instance(void)
Definition Configuration.cpp:29
void setSupportedServices(const std::list< ServiceInformation > &_services)
Definition Configuration.h:39
unsigned int defaultMaxStartupRestarts(void) const
Definition Configuration.h:52
void setLauncherPath(const std::string &_launcherPath)
Definition Configuration.h:42
unsigned int defaultMaxCrashRestarts(void) const
Definition Configuration.h:49
void setDefaultMaxCrashRestarts(unsigned int _restarts)
Definition Configuration.h:48
bool supportsService(const std::string &_serviceName) const
Returns true if the provided service is supported by this LDS.
Definition Configuration.cpp:165
void setServicesLibraryPath(const std::string &_path)
Definition Configuration.h:45
void setDefaultMaxStartupRestarts(unsigned int _restarts)
Definition Configuration.h:51
virtual void setFromJsonObject(const ot::ConstJsonObject &_object) override
Will set the object contents from the provided JSON object.
Definition Configuration.cpp:49
int importFromEnvironment(void)
Will load the confiuguration from the environment Returns an exit code (use LDS_EXIT_....
Definition Configuration.cpp:139
virtual void addToJsonObject(ot::JsonValue &_object, ot::JsonAllocator &_allocator) const override
Add the object contents to the provided JSON object.
Definition Configuration.cpp:34
const std::string & servicesLibraryPath(void) const
Definition Configuration.h:46
const std::string launcherPath(void) const
Definition Configuration.h:43
The Serializable class is the default interface of serializable objects.
Definition Serializable.h:17
rapidjson::Value JsonValue
Writable JSON value.
Definition JSON.h:27
rapidjson::GenericObject< true, rapidjson::GenericValue< rapidjson::UTF8<>, rapidjson::MemoryPoolAllocator< rapidjson::CrtAllocator > > > ConstJsonObject
Read only JSON Object.
Definition JSON.h:35
rapidjson::MemoryPoolAllocator< rapidjson::CrtAllocator > JsonAllocator
Allocator used for writing to JSON values.
Definition JSON.h:30