State Machine
Tools for creating and running general purpose state machines.
state_machine::GlobalDataInterface Class Reference

#include <GlobalDataInterface.hpp>

Public Member Functions

 GlobalDataInterface ()=default
 
 ~GlobalDataInterface ()=default
 
void registerKey (const std::string &key)
 
bool keyIsRegistered (const std::string &key)
 
std::set< std::string > getKeys ()
 
template<typename T >
void setValue (const std::string &key, const T &value)
 
template<typename T >
bool getValue (const std::string &key, T &value)
 

Protected Attributes

std::mutex dataMutex_
 
std::map< std::string, std::shared_ptr< boost::any > > data_
 

Detailed Description

Interface to the global data. Can store any type of data, accessible by all states.

Constructor & Destructor Documentation

◆ GlobalDataInterface()

state_machine::GlobalDataInterface::GlobalDataInterface ( )
default

Constructor.

◆ ~GlobalDataInterface()

state_machine::GlobalDataInterface::~GlobalDataInterface ( )
default

Destructor.

Member Function Documentation

◆ getKeys()

std::set< std::string > state_machine::GlobalDataInterface::getKeys ( )

Get all registered keys.

Returns
All registered keys.

◆ getValue()

template<typename T >
bool state_machine::GlobalDataInterface::getValue ( const std::string &  key,
T &  value 
)
inline

Get a value.

Parameters
keyKey to get value for.
valueReturn argument, will contain value if successful.
Returns
True if successful.

◆ keyIsRegistered()

bool state_machine::GlobalDataInterface::keyIsRegistered ( const std::string &  key)

Check if a key is registered.

Parameters
keyKey to check for.

◆ registerKey()

void state_machine::GlobalDataInterface::registerKey ( const std::string &  key)

Register a new key.

Parameters
keyKey to register.

◆ setValue()

template<typename T >
void state_machine::GlobalDataInterface::setValue ( const std::string &  key,
const T &  value 
)
inline

Set a value. TODO return false?

Parameters
keyKey to set value for.
valueValue to set.

Member Data Documentation

◆ data_

std::map<std::string, std::shared_ptr<boost::any> > state_machine::GlobalDataInterface::data_
protected

◆ dataMutex_

std::mutex state_machine::GlobalDataInterface::dataMutex_
protected

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