ifw-sup  3.0.0-pre3
Public Member Functions | List of all members
sup::syssup::common::DataContext Class Reference

#include <dataContext.hpp>

Public Member Functions

 DataContext (Config &config, bool with_publisher=true, bool with_oldb=true)
 
virtual ~DataContext ()
 
void ReloadConfig ()
 
void UpdateDb ()
 
ConfigGetConfig ()
 
State::StateEnum GetState ()
 Get server actual state. More...
 
void SetState (const State::StateEnum state)
 Set server actual state. More...
 
void SetState (const std::string &state)
 Set server actual state. More...
 
State::SubstateEnum GetSubstate ()
 Get server actual substate. More...
 
void SetSubstate (const State::SubstateEnum state)
 Set server actual substate. More...
 
void SetSubstate (const std::string &state)
 Set server actual substate. More...
 
State::StateEnum GetEstimatedState ()
 Get actual estimated state. More...
 
std::string GetEstimatedStateStr ()
 Set actual estimated state as string. More...
 
void SetEstimatedState (const State::StateEnum state)
 Set actual estimated state. More...
 
std::string GetEstimatedSubstateStr ()
 Get actual estimated substate as string. More...
 
State::SubstateEnum GetEstimatedSubstate ()
 Get actual estimated substate. More...
 
void SetEstimatedSubstate (const State::SubstateEnum state)
 Set actual estimated substate. More...
 
void UpdateSubsysStates (const std::string &name, const std::string &state, const std::string &substate)
 
void PublishStates ()
 Publish actual states. More...
 

Detailed Description

This class provide access to the application run-time data including the in-memory DB. This class also takes care of publishing the status information

This class write the supervisor configuration and runtime data into the OLDB. The DB structure used is the following:

<prefix>/<server_id>: | |–cfg | – server_id – ... |–states | |– state |– substate |–subsystems | – subsys1 | | – states | |– state |– substate

The publishing of the status is the estimated state/substate of the supervisor and it follows the following convention.

 <endpoint>/std/status

The topic is used is the one defined in the standard interface which is a string with the following format: <state>;<substate>

Constructor & Destructor Documentation

◆ DataContext()

sup::syssup::common::DataContext::DataContext ( Config config,
bool  with_publisher = true,
bool  with_oldb = true 
)

This constructor uses the application configuration to initialize the adapter object to the in-memory DB. The DB adapter is then used to initialize the DB interface object that can be used to access the DB key-value pairs.

Parameters
[in]configReference to the application configuration.
[in]with_publisherFlag to enable/disable the publishing used in unit tests.
[in]with_oldbFlag to enable/disable the DB writes used in unit tests.

◆ ~DataContext()

sup::syssup::common::DataContext::~DataContext ( )
virtual

Destructor

Member Function Documentation

◆ GetConfig()

Config & sup::syssup::common::DataContext::GetConfig ( )
Returns
A reference to the Config object.

◆ GetEstimatedState()

State::StateEnum sup::syssup::common::DataContext::GetEstimatedState ( )

Get actual estimated state.

Returns

◆ GetEstimatedStateStr()

std::string sup::syssup::common::DataContext::GetEstimatedStateStr ( )

Set actual estimated state as string.

Returns

◆ GetEstimatedSubstate()

State::SubstateEnum sup::syssup::common::DataContext::GetEstimatedSubstate ( )

Get actual estimated substate.

Returns

◆ GetEstimatedSubstateStr()

std::string sup::syssup::common::DataContext::GetEstimatedSubstateStr ( )

Get actual estimated substate as string.

Returns

◆ GetState()

State::StateEnum sup::syssup::common::DataContext::GetState ( )

Get server actual state.

Returns

◆ GetSubstate()

State::SubstateEnum sup::syssup::common::DataContext::GetSubstate ( )

Get server actual substate.

Returns

◆ PublishStates()

void sup::syssup::common::DataContext::PublishStates ( )

Publish actual states.

It updates the OLDB and publish status via CII pub/sub.

◆ ReloadConfig()

void sup::syssup::common::DataContext::ReloadConfig ( )

Reload the configuration from file and reconnect to the in-memory DB.

◆ SetEstimatedState()

void sup::syssup::common::DataContext::SetEstimatedState ( const State::StateEnum  state)

Set actual estimated state.

Parameters
statenew state as string

◆ SetEstimatedSubstate()

void sup::syssup::common::DataContext::SetEstimatedSubstate ( const State::SubstateEnum  state)

Set actual estimated substate.

Parameters
statenew substate as string

◆ SetState() [1/2]

void sup::syssup::common::DataContext::SetState ( const State::StateEnum  state)

Set server actual state.

Parameters
statenew state as enumeration

◆ SetState() [2/2]

void sup::syssup::common::DataContext::SetState ( const std::string &  state)

Set server actual state.

Parameters
statenew state as string

◆ SetSubstate() [1/2]

void sup::syssup::common::DataContext::SetSubstate ( const State::SubstateEnum  state)

Set server actual substate.

Parameters
statenew substate as enumeration

◆ SetSubstate() [2/2]

void sup::syssup::common::DataContext::SetSubstate ( const std::string &  state)

Set server actual substate.

Parameters
statenew substate as string

◆ UpdateDb()

void sup::syssup::common::DataContext::UpdateDb ( )

Try to connect to the DB and update the application configuration.

◆ UpdateSubsysStates()

void sup::syssup::common::DataContext::UpdateSubsysStates ( const std::string &  name,
const std::string &  state,
const std::string &  substate 
)

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