ifw-sup  1.0.0
Public Member Functions | List of all members
sup::subsim::common::Config Class Reference

#include <config.hpp>

Inheritance diagram for sup::subsim::common::Config:
sup::subsim::common::IConfig

Public Member Functions

 Config ()
 
virtual ~Config ()
 
bool ParseOptions (int argc, char *argv[])
 
void LoadConfig (const std::string &filename="")
 
const std::string GetServerId () const
 
const std::string GetMsgReplierEndpoint () const
 
const std::string GetDbEndpoint () const
 
const std::string GetPubEndpoint () const
 
const timeval GetDbTimeout () const
 
const std::string GetSmScxmlFilename () const
 
const std::string GetConfigFilename () const
 
const std::string GetProcName () const
 
const std::string GetLogLevel () const
 
std::optional< bool > GetReplyOk (const std::string &name) const
 
std::optional< int > GetReplyDelay (const std::string &name) const
 
std::optional< std::string > GetReplyErrorMessage (const std::string &name) const
 
ReplyConfigDataGetCmdReplyData (const std::string &name)
 
virtual void GetConfigList (std::vector< std::string > &cfg_list)
 Get configuration list. More...
 
const unsigned int GetCmdTout ()
 GetCmdTout. More...
 
const int GetNumCommands () override
 
const std::string GetCommandName (const int &cmd_index)
 
void SetCmdTout (const unsigned int cmd_tout)
 SetCmdTout. More...
 
const std::string GetConfigAsString () const
 Get the actual configuration as a string. More...
 
void SetReplyOk (const std::string &name, const bool &flag)
 
void SetReplyDelay (const std::string &name, const int &delay)
 
void SetReplyErrorMessage (const std::string &name, const std::string &msg)
 
 Config (const Config &)=delete
 
Configoperator= (const Config &)=delete
 Disable copy constructor. More...
 

Detailed Description

This class provide access to the command line options and the configuration parameters stored in the configuration file.

Constructor & Destructor Documentation

◆ Config() [1/2]

sup::subsim::common::Config::Config ( )

Default constructor.

Initialize application configuration attributes by

  • first use the default constant values defined in the header
  • override the constant values with environment variables (if defined)

◆ ~Config()

sup::subsim::common::Config::~Config ( )
virtual

Default destructor.

◆ Config() [2/2]

sup::subsim::common::Config::Config ( const Config )
delete

Member Function Documentation

◆ GetCmdReplyData()

ReplyConfigData * sup::subsim::common::Config::GetCmdReplyData ( const std::string &  name)
virtual

◆ GetCmdTout()

const unsigned int sup::subsim::common::Config::GetCmdTout ( )
virtual

GetCmdTout.

Returns

Implements sup::subsim::common::IConfig.

◆ GetCommandName()

const std::string sup::subsim::common::Config::GetCommandName ( const int &  cmd_index)

◆ GetConfigAsString()

const std::string sup::subsim::common::Config::GetConfigAsString ( ) const
virtual

Get the actual configuration as a string.

Implements sup::subsim::common::IConfig.

◆ GetConfigFilename()

const std::string sup::subsim::common::Config::GetConfigFilename ( ) const
virtual
Returns
The application configuration filename.

Implements sup::subsim::common::IConfig.

◆ GetConfigList()

void sup::subsim::common::Config::GetConfigList ( std::vector< std::string > &  cfg_list)
virtual

Get configuration list.

Parameters
cfg_listList of all configuration parameters.

This method returs the complete of configuration parameters handled by this class. This method is used to dump the list into the DB.

Implements sup::subsim::common::IConfig.

◆ GetDbEndpoint()

const std::string sup::subsim::common::Config::GetDbEndpoint ( ) const
virtual
Returns
The IP address and port used to connect to the runtime DB.

Implements sup::subsim::common::IConfig.

◆ GetDbTimeout()

const timeval sup::subsim::common::Config::GetDbTimeout ( ) const
virtual
Returns
The timeout used when communicating to the runtime DB.

Implements sup::subsim::common::IConfig.

◆ GetLogLevel()

const std::string sup::subsim::common::Config::GetLogLevel ( ) const
virtual
Returns
The configured log level.

Implements sup::subsim::common::IConfig.

◆ GetMsgReplierEndpoint()

const std::string sup::subsim::common::Config::GetMsgReplierEndpoint ( ) const
virtual
Returns
The network endpoint to send request to this application. The format is "\<protocol\>://\<ipaddr\>:\<port\>" where <protocol> is 'tcp' For example: "tcp://127.0.0.1:5577"

Implements sup::subsim::common::IConfig.

◆ GetNumCommands()

const int sup::subsim::common::Config::GetNumCommands ( )
overridevirtual

◆ GetProcName()

const std::string sup::subsim::common::Config::GetProcName ( ) const
virtual
Returns
The application process name.

Implements sup::subsim::common::IConfig.

◆ GetPubEndpoint()

const std::string sup::subsim::common::Config::GetPubEndpoint ( ) const
virtual
Returns
The network endpoint to publish internally within the application. The format is the CII URI For example: "zpb.rr://127.0.0.1:12081/AppCmds"

Implements sup::subsim::common::IConfig.

◆ GetReplyDelay()

std::optional< int > sup::subsim::common::Config::GetReplyDelay ( const std::string &  name) const
virtual

◆ GetReplyErrorMessage()

std::optional< std::string > sup::subsim::common::Config::GetReplyErrorMessage ( const std::string &  name) const
virtual

◆ GetReplyOk()

std::optional< bool > sup::subsim::common::Config::GetReplyOk ( const std::string &  name) const
virtual

◆ GetServerId()

const std::string sup::subsim::common::Config::GetServerId ( ) const
virtual
Returns
return the server identifier

Implements sup::subsim::common::IConfig.

◆ GetSmScxmlFilename()

const std::string sup::subsim::common::Config::GetSmScxmlFilename ( ) const
virtual
Returns
The SCXML State Machine model filename used by the application.

Implements sup::subsim::common::IConfig.

◆ LoadConfig()

void sup::subsim::common::Config::LoadConfig ( const std::string &  filename = "")
virtual

This method load from a configuration file the application configuration overriding the initialization done in the constructor and the command line options.

Parameters
[in]filenameApplication configuration filename.

Implements sup::subsim::common::IConfig.

◆ operator=()

Config& sup::subsim::common::Config::operator= ( const Config )
delete

Disable copy constructor.

◆ ParseOptions()

bool sup::subsim::common::Config::ParseOptions ( int  argc,
char *  argv[] 
)
virtual

This method parses the command line parameters overriding the initialization done in the constructor.

Parameters
[in]argcNumber of command line options.
[in]argvPointer to the array of command line options.
Returns
false if the help option has been invoked, true otherwise.

Implements sup::subsim::common::IConfig.

◆ SetCmdTout()

void sup::subsim::common::Config::SetCmdTout ( const unsigned int  cmd_tout)

SetCmdTout.

Parameters
cmd_toutnew command timeout

◆ SetReplyDelay()

void sup::subsim::common::Config::SetReplyDelay ( const std::string &  name,
const int &  delay 
)
virtual

◆ SetReplyErrorMessage()

void sup::subsim::common::Config::SetReplyErrorMessage ( const std::string &  name,
const std::string &  msg 
)
virtual

◆ SetReplyOk()

void sup::subsim::common::Config::SetReplyOk ( const std::string &  name,
const bool &  flag 
)
virtual

The documentation for this class was generated from the following files: