ifw-core 5.0.1
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | List of all members
utils::bat::DbInterface Class Reference

#include <dbInterface.hpp>

Public Member Functions

 DbInterface (const std::string &prefix, std::chrono::seconds db_timeout, std::chrono::milliseconds db_task_period, bool with_worker_thread=true)
 
virtual ~DbInterface ()
 
bool IsConnected ()
 
std::string GetPrefix ()
 
void SetStates (const std::string &prefix, const std::string &state, const std::string &substate)
 
template<typename T >
void Get (const std::string &key, T &value)
 
template<typename T >
void Set (const std::string &key, const T &value)
 
template<typename T >
void SetAsync (const std::string &key, const T &value)
 Aynchronous OLDB set for single attributes.
 
void BatchSetAsync (const DbVector &vec)
 Aynchronous OLDB set for a vector.
 
 DbInterface (const DbInterface &)=delete
 Disable copy constructor.
 
DbInterfaceoperator= (const DbInterface &)=delete
 Disable assignment operator.
 

Detailed Description

This class is the interface to the in-memory DB.

Constructor & Destructor Documentation

◆ DbInterface() [1/2]

utils::bat::DbInterface::DbInterface ( const std::string &  prefix,
std::chrono::seconds  db_timeout,
std::chrono::milliseconds  db_task_period,
bool  with_worker_thread = true 
)

Constructor.

Parameters
[in]prefixString used as prefix when building the keys.
[in]runtime_dbReference to the in-memory DB adapter.

◆ ~DbInterface()

utils::bat::DbInterface::~DbInterface ( )
virtual

Destructor

◆ DbInterface() [2/2]

utils::bat::DbInterface::DbInterface ( const DbInterface )
delete

Disable copy constructor.

Member Function Documentation

◆ BatchSetAsync()

void utils::bat::DbInterface::BatchSetAsync ( const DbVector vec)

Aynchronous OLDB set for a vector.

Parameters
[in]vecVector containing the attributes to write

This methods allows client application to pass one attribute to be written. The attributes will be added to the internal double map that will be later written into the OLDB by the dedicated OLDB worker thread.

◆ Get()

template<typename T >
void utils::bat::DbInterface::Get ( const std::string &  key,
T &  value 
)

Read the value associated to a given key.

Parameters
[in]keyURI of the attribute.
[out]valueIf the key is accessible, the value associated to the key.

◆ GetPrefix()

std::string utils::bat::DbInterface::GetPrefix ( )
inline

◆ IsConnected()

bool utils::bat::DbInterface::IsConnected ( )
inline

◆ operator=()

DbInterface & utils::bat::DbInterface::operator= ( const DbInterface )
delete

Disable assignment operator.

◆ Set()

template<typename T >
void utils::bat::DbInterface::Set ( const std::string &  key,
const T &  value 
)

Write a value for the given key.

Parameters
[in]keyURI of the attribute.
[in]valueThe value associated to the key.

◆ SetAsync()

template<typename T >
void utils::bat::DbInterface::SetAsync ( const std::string &  key,
const T &  value 
)

Aynchronous OLDB set for single attributes.

Parameters
[in]keyURI of the attribute to be written.
[in]valueValue to be written.

This methods allows client application to write attributes into the OLDB asynchronously. Each of these attributes will be added to the internal double map that will be later written into the OLDB by the dedicated OLDB worker thread.

◆ SetStates()

void utils::bat::DbInterface::SetStates ( const std::string &  prefix,
const std::string &  state,
const std::string &  substate 
)

Writes the application states information into the DB.

Parameters
[in]prefixto be used for the key.
[in]stateState to be stored in the DB.
[in]substateSubstate to be stored in the DB.

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