|
dodo
0.0.1
A C++ library to create containerized Linux services
|
Red tape wrapper class for applications, from command line to services. More...
#include <application.hpp>

Data Structures | |
| struct | StartParameters |
| Start parameters for the Application. More... | |
Public Types | |
| enum | HostType { HostType::BareMetal, HostType::Docker, HostType::VirtualBox, HostType::VMWare, HostType::KVM, HostType::GenericVM } |
| The type of host the Application is running on. More... | |
Public Member Functions | |
| Application (const StartParameters ¶m) | |
| Construct an Application instance. More... | |
| virtual | ~Application () |
| Destructor. More... | |
| HostType | getHostType () const |
| Return the HostType the Application is running on. More... | |
| bool | hasStopRequest () const |
| Return true when the main thread got a SIGTERM or SIGQUIT. More... | |
| virtual int | run () |
| Override. More... | |
Static Public Member Functions | |
| static std::string | getHostTypeAsString (HostType ht) |
| Convert a HostType to a human readable string. More... | |
Private Member Functions | |
| HostType | detectHostType () |
| Detect the HostType of the host the Application is running on. More... | |
| void | installSignalHandlers () |
| Install the signal handlers. More... | |
| void | onSignal (int signal) |
| Called by signal_handler. More... | |
Static Private Member Functions | |
| static void | signal_handler (int signal) |
| Signal handler called by the OS. More... | |
Private Attributes | |
| std::string | config_file_ |
| The configuration file name. More... | |
| bool | has_stop_request_ |
| True when the Application main pid got a signal to stop (SIGTERM). More... | |
| HostType | hosttype_ |
| The HostType, detected once in the Application constructor. More... | |
| Logger * | logger_ |
| The Logger. More... | |
Static Private Attributes | |
| static Application * | application_ = nullptr |
| Singleton Application object. More... | |
Red tape wrapper class for applications, from command line to services.
The Application class
Definition at line 61 of file application.hpp.
|
strong |
The type of host the Application is running on.
| Enumerator | |
|---|---|
| BareMetal | Bare metal deployment. |
| Docker | Docker container. |
| VirtualBox | VirtualBox. |
| VMWare | VMWare. |
| KVM | RedHat KVM. |
| GenericVM | An indeterminate virtual machine. |
Definition at line 67 of file application.hpp.
| dodo::common::Application::Application | ( | const StartParameters & | param | ) |
Construct an Application instance.
| param | The Application start parameters. |
| dodo::common::Exception | when the name is empty, the config file is not empty and invalid. |
Definition at line 33 of file application.cpp.
References application_, dodo::common::Application::StartParameters::config, detectHostType(), dodo::common::Config::getAppName(), getHostTypeAsString(), has_stop_request_, hosttype_, dodo::common::Logger::Info, dodo::common::Logger::initialize(), dodo::common::Config::initialize(), dodo::initLibrary(), installSignalHandlers(), dodo::common::Logger::log(), and logger_.

|
virtual |
Destructor.
Definition at line 44 of file application.cpp.
References dodo::closeLibrary(), dodo::common::Config::config_, and dodo::common::Logger::logger_.

|
private |
Detect the HostType of the host the Application is running on.
Definition at line 85 of file application.cpp.
References BareMetal, Docker, dodo::common::fileReadAccess(), dodo::common::fileReadStrings(), GenericVM, KVM, VirtualBox, and VMWare.
Referenced by Application().


|
inline |
Return the HostType the Application is running on.
Definition at line 103 of file application.hpp.
References hosttype_.
|
static |
Convert a HostType to a human readable string.
| ht | The HostType to convert. |
Definition at line 50 of file application.cpp.
References BareMetal, Docker, GenericVM, KVM, VirtualBox, and VMWare.
Referenced by Application().

|
inline |
Return true when the main thread got a SIGTERM or SIGQUIT.
Definition at line 109 of file application.hpp.
References has_stop_request_.
|
private |
Install the signal handlers.
Definition at line 66 of file application.cpp.
References signal_handler().
Referenced by Application().


|
private |
Called by signal_handler.
Note that this call can be made at any time interrupting the current thread, but no need for synchronization setting has_stop_request_ to true, other threads only read it.
| signal | The received signal. |
Definition at line 72 of file application.cpp.
References has_stop_request_, and log_Warning.
Referenced by signal_handler().

|
inlinevirtual |
Override.
Definition at line 124 of file application.hpp.
|
staticprivate |
Signal handler called by the OS.
Depends on application_ to be valid.
| signal | the signal received. |
Definition at line 62 of file application.cpp.
References application_, and onSignal().
Referenced by installSignalHandlers().


|
staticprivate |
Singleton Application object.
Definition at line 155 of file application.hpp.
Referenced by Application(), and signal_handler().
|
private |
The configuration file name.
Definition at line 160 of file application.hpp.
|
private |
True when the Application main pid got a signal to stop (SIGTERM).
Definition at line 170 of file application.hpp.
Referenced by Application(), hasStopRequest(), and onSignal().
|
private |
The HostType, detected once in the Application constructor.
Definition at line 165 of file application.hpp.
Referenced by Application(), and getHostType().
|
private |