VISR  0.11.7
Versatile Interactive Scene Renderer
visr::CommunicationProtocolFactory Class Reference

#include <communication_protocol_factory.hpp>

Public Member Functions

 CommunicationProtocolFactory ()=delete
 

Static Public Member Functions

static std::unique_ptr< CommunicationProtocolBasecreateProtocol (CommunicationProtocolType const &protocolType, ParameterType const &paramType, ParameterConfigBase const &config)
 
static std::unique_ptr< CommunicationProtocolBase::InputcreateInput (CommunicationProtocolType const &protocolType)
 
static std::unique_ptr< CommunicationProtocolBase::OutputcreateOutput (CommunicationProtocolType const &protocolType)
 
static std::size_t numberOfProtocols () noexcept
 
static CommunicationProtocolType typeFromName (char const *name)
 
static std::string typeToName (CommunicationProtocolType type)
 
static bool typeExists (CommunicationProtocolType type) noexcept
 
template<class ConcreteCommunicationProtocol >
static void registerCommunicationProtocol (CommunicationProtocolType const &protocolType, char const *name)
 
template<class ConcreteCommunicationProtocol >
static void registerCommunicationProtocol ()
 

Detailed Description

Class encapsulating functionality to retrieve information about and to create communication protocol objects and related objects.

Constructor & Destructor Documentation

◆ CommunicationProtocolFactory()

visr::CommunicationProtocolFactory::CommunicationProtocolFactory ( )
delete

Deleted default constructor as this class is to be used only through static functions.

Member Function Documentation

◆ createInput()

std::unique_ptr< CommunicationProtocolBase::Input > visr::CommunicationProtocolFactory::createInput ( CommunicationProtocolType const &  protocolType)
static

Create an input end point which accepts the data from a protocol (typically sitting in a parameter input port).

Parameters
protocolTypeThe type id of the communication protocol for which the input end point is going to be created.
Returns
A dynamically allocated object contained in a std::unique_ptr. The caller is responsible for freeing this object (done automatically if it is kept in a smart pointer).
Exceptions
std::out_of_rangeIf no protocol with type id protocolType is registered in the factory.

◆ createOutput()

std::unique_ptr< CommunicationProtocolBase::Output > visr::CommunicationProtocolFactory::createOutput ( CommunicationProtocolType const &  protocolType)
static

Create an output end point that receives data and transmits it to a protocol object (typically sitting in a parameter output port).

Parameters
protocolTypeThe type id of the communication protocol for which the output end point is going to be created.
Returns
A dynamically allocated object contained in a std::unique_ptr. The caller is responsible for freeing this object (done automatically if it is kept in a smart pointer).
Exceptions
std::out_of_rangeIf no protocol with type id protocolType is registered in the factory.

◆ createProtocol()

std::unique_ptr< CommunicationProtocolBase > visr::CommunicationProtocolFactory::createProtocol ( CommunicationProtocolType const &  protocolType,
ParameterType const &  paramType,
ParameterConfigBase const &  config 
)
static

Create a communication protocol object based of a given protocol type. This function does not need to be used by user API users.

Parameters
protocolTypeThe type id of the requested communication protocol.
paramTypeThe type id of the parameter type to be transmitted by the protocol.
configA parameter configuration object holding configuration data about the parameter objects to be created and transmitted by the protocol. This object is to be copied internally, therefore the lifetime of the referenced object needs to persist only for the durarion of the function call.
Returns
A dynamically allocated object contained in a std::unique_ptr. The caller is responsible for freeing this object (done automatically if it is kept in a smart pointer).
Exceptions
std::out_of_rangeIf no protocol with type id protocolType is registered in the factory.

◆ numberOfProtocols()

std::size_t visr::CommunicationProtocolFactory::numberOfProtocols ( )
staticnoexcept

Return the number of registered protocols.

◆ registerCommunicationProtocol() [1/2]

template<class ConcreteCommunicationProtocolType >
void visr::CommunicationProtocolFactory::registerCommunicationProtocol ( CommunicationProtocolType const &  protocolType,
char const *  name 
)
static

Template method to register a concrete communication protocol in the factory. This method also registers creation methods for the input and output endpoints that are used by createInput() and createOutput().

Template Parameters
ConcreteCommunicationProtocolThe protocol class type. The full definition must be visible for instantiating this template.
Parameters
protocolTypeThe type id used to register the protocol.
nameA name associated with this protocol, used for tuntime lookup of type ids and associated types.
Exceptions
std::invalid_argumentIf a protocol is already registered for this protocol id or if the name is already used for a different type.

◆ registerCommunicationProtocol() [2/2]

template<class ConcreteCommunicationProtocolType >
void visr::CommunicationProtocolFactory::registerCommunicationProtocol ( )
static

Template method to register a concrete communication protocol in the factory. Information about the protocol type and the name are taken from the CommunicationProtocolToId and IdToCommunicationProtocol type traits (normally set by the DEFINE_COMMUNICATION_PROTOCOL macro). These specialisations must be visible at the point where the template method is called. This method also registers creation methods for the input and output endpoints that are used by createInput() and createOutput().

Template Parameters
ConcreteCommunicationProtocolThe protocol class type. The full definition must be visible for instantiating this template.
Exceptions
std::invalid_argumentIf a protocol is already registered for this protocol id or if the name is already used for a different type.

◆ typeExists()

bool visr::CommunicationProtocolFactory::typeExists ( CommunicationProtocolType  type)
staticnoexcept

Query if a protocol with the given id is registered in the factory

Returns
True if the protocol is regitered, false otherwise.

◆ typeFromName()

CommunicationProtocolType visr::CommunicationProtocolFactory::typeFromName ( char const *  name)
static

Return the registered name of a protocol.

Exceptions
std::invalid_argumentif no protocol with this name exists.

◆ typeToName()

std::string visr::CommunicationProtocolFactory::typeToName ( CommunicationProtocolType  type)
static

Lookup the protocol type for a name.

Exceptions
std::invalid_argumentif no protocol with this name has been registered.
Todo:
Consider changing the return type to char const *

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