DUNE: Uniform Navigational Environment  2019.02.0
DUNE::Entities::EntityDataBase Class Reference

Classes

struct  Entity
 
struct  InvalidId
 
struct  InvalidLabel
 
struct  NonexistentLabel
 
struct  ReservedUnique
 

Public Member Functions

 EntityDataBase (void)
 
 ~EntityDataBase (void)
 
bool labelExists (const std::string &name)
 
bool idExists (unsigned int id)
 
unsigned int reserve (const std::string &label, const std::string &task_name)
 
unsigned int resolve (const std::string &label)
 
std::string resolveTaskName (const std::string &label)
 
const std::string & resolve (unsigned int id)
 
void contents (std::vector< Entity * > &devs)
 
std::map< unsigned, std::string > entries (void)
 

Constructor & Destructor Documentation

DUNE::Entities::EntityDataBase::EntityDataBase ( void  )
inline

Constructor.

DUNE::Entities::EntityDataBase::~EntityDataBase ( void  )
inline

Destructor.

Member Function Documentation

void DUNE::Entities::EntityDataBase::contents ( std::vector< Entity * > &  devs)
inline

Fill a vector with pointers to the existing Entity records.

Parameters
[out]devsvector to be filled.

Referenced by DUNE::Daemon::consume(), Monitors::Entities::Task::onEntityResolution(), and Transports::LoggingDigest::Task::startLog().

std::map<unsigned, std::string> DUNE::Entities::EntityDataBase::entries ( void  )
inline

Produce a map between the existing numeric entity ids and the entity labels.

Returns
the produced map.
bool DUNE::Entities::EntityDataBase::idExists ( unsigned int  id)
inline

Determine if an entity identified by a given numeric id exists in the database.

Parameters
[in]idnumeric id to use.
Returns
true if an entity with the provided id exists in the database, false otherwise.
bool DUNE::Entities::EntityDataBase::labelExists ( const std::string &  name)
inline

Determine if an entity identified by a given label exists in the database.

Parameters
[in]nameentity label to use.
Returns
true if an entity with the provided label exists in the database, false otherwise.
unsigned int DUNE::Entities::EntityDataBase::reserve ( const std::string &  label,
const std::string &  task_name 
)
inline

Add an entity to the database, identified by a unique label, and retrieve the reserved numerical id.

Parameters
[in]labelthe desired entity label.
[in]task_namethe name of the task owning the entity.
Returns
reserved numerical id.

References DUNE::Entities::EntityDataBase::Entity::id, DUNE::Entities::EntityDataBase::Entity::label, and DUNE::Entities::EntityDataBase::Entity::task_name.

Referenced by DUNE::Tasks::Task::reserveEntities(), and DUNE::Tasks::Task::reserveEntity().

unsigned int DUNE::Entities::EntityDataBase::resolve ( const std::string &  label)
inline

Get the numeric id for the entity identified by the given label The NonexistentLabel exception is thrown if there is no matching entity in the database.

Returns
numerical entity id.

Referenced by Sensors::DataStore::Task::onEntityResolution(), Transports::DataStore::Task::process(), DUNE::Tasks::Task::resolveEntity(), and DUNE::Entities::BasicEntity::setLabel().

const std::string& DUNE::Entities::EntityDataBase::resolve ( unsigned int  id)
inline

Get the label for the entity identified by the given numeric id.

The InvalidId exception is thrown if there is no matching entity in the database.

Returns
entity label.
std::string DUNE::Entities::EntityDataBase::resolveTaskName ( const std::string &  label)
inline

Get the task name for the entity identified by the given label The NonexistentLabel exception is thrown if there is no matching entity in the database.

Returns
task name.

Referenced by DUNE::Daemon::consume().

Collaboration diagram for DUNE::Entities::EntityDataBase:
Collaboration graph