RTC Toolkit  0.1.0-alpha
Public Member Functions | List of all members
rtctk::componentFramework::ServiceContainer Class Reference

#include <serviceContainer.hpp>

Public Member Functions

template<typename Service >
void Add (Service &&service, const std::string &name="")
 
template<typename Service >
void Add (std::shared_ptr< Service > service, const std::string &name="")
 
template<typename Service >
Service & Get (const std::string &name="")
 
template<typename Service >
bool Contains (const std::string &name="")
 
std::vector< std::string > List ()
 

Detailed Description

Container class that holds services of any type.

The class holds services which are identified by their type and name. Multiple services can be registered for a certain type. Users may request handles to these services.

Polymorphic services can be added as a specific type and retrieved as a generic type

Member Function Documentation

◆ Add() [1/2]

template<typename Service >
void rtctk::componentFramework::ServiceContainer::Add ( Service &&  service,
const std::string &  name = "" 
)
inline

Insert new service into the container

This overload is used to add non-pointer type serives, which are moved into the container

Template Parameters
Service,typeof the service.
Parameters
servicervalue ref to the service.
namename of the service.
Exceptions
std::runtime_errorif service already registered

◆ Add() [2/2]

template<typename Service >
void rtctk::componentFramework::ServiceContainer::Add ( std::shared_ptr< Service >  service,
const std::string &  name = "" 
)
inline

Insert new service into the container

This overload is used to add shared_pointer type serives, which are copied into the container

Template Parameters
Service,typeof the service.
Parameters
servicervalue ref to the service.
namename of the service.
Exceptions
std::runtime_errorif service already registered

◆ Contains()

template<typename Service >
bool rtctk::componentFramework::ServiceContainer::Contains ( const std::string &  name = "")
inline

Check if the service container holds a certain service

Template Parameters
Service,typeof the service.
Parameters
nameoptional: name of the service, if only 1 service of type Service is present, this argument can be ommited
Returns
true, if service is present, otherwise false

◆ Get()

template<typename Service >
Service& rtctk::componentFramework::ServiceContainer::Get ( const std::string &  name = "")
inline

Get a handle to a service

Template Parameters
Service,typeof the service.
Parameters
nameoptional: name of the service, if only 1 service of type Service is present, this argument can be ommited
Returns
service handle by reference
Exceptions
std::runtime_errorif service not found

◆ List()

std::vector< std::string > rtctk::componentFramework::ServiceContainer::List ( )

List currently available services

Returns
vector of strings that describe services

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