RSB  0.7.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
rsb::ParticipantConfig Class Reference

A class describing the configuration of Participant instances. More...

#include <ParticipantConfig.h>

Inheritance diagram for rsb::ParticipantConfig:
Inheritance graph
Collaboration diagram for rsb::ParticipantConfig:
Collaboration graph

Classes

class  EventProcessingStrategy
 Instances of this class describe the selection and configuration of an event processing strategy. More...
class  Transport
 Description of a desired transport. More...

Public Types

enum  ErrorStrategy { LOG, PRINT, EXIT }
 Possible error handling strategies in user-provided code like event handlers. More...

Public Member Functions

 ParticipantConfig ()
 Constructs a new empty configuration using the default QoS settings and LOG as error strategy.
virtual ~ParticipantConfig ()
QualityOfServiceSpec getQualityOfServiceSpec () const
 Returns the current settings for QoS.
QualityOfServiceSpecmutableQualityOfServiceSpec ()
 Returns mutable quality of service settings.
void setQualityOfServiceSpec (const QualityOfServiceSpec &spec)
 Sets the desired QoS settings.
ErrorStrategy getErrorStrategy () const
 Returns the selected error strategy for the configured participant.
void setErrorStrategy (const ErrorStrategy &strategy)
 Sets the desired error strategy for the participant.
std::set< TransportgetTransports (bool includeDisabled=false) const
 Returns the set of desired transports for a participant.
Transport getTransport (const std::string &name) const
 Returns an immutable copy of a single configured transport.
TransportmutableTransport (const std::string &name)
 Returns a single configured transport which can be modified in place.
void addTransport (const Transport &transport)
 Adds a transport to the list of desired transport mechanisms.
void removeTransport (const Transport &transport)
 Removes a transport from the list of desired transports if it was present.
void setTransports (const std::set< Transport > &transports)
 Sets all desired transports in this configuration.
const EventProcessingStrategygetEventReceivingStrategy () const
EventProcessingStrategymutableEventReceivingStrategy ()
const EventProcessingStrategygetEventSendingStrategy () const
rsc::runtime::Properties getOptions () const
 Returns additional options besides the transport-specific ones.
rsc::runtime::Properties & mutableOptions ()
 Returns a mutable reference to the freestyle options in this configuration.
void setOptions (const rsc::runtime::Properties &options)
 Sets the additional options besides the transport-specific ones.

Static Public Member Functions

static ParticipantConfig fromFile (const boost::filesystem::path &path, const ParticipantConfig &defaults=ParticipantConfig())
 Obtain configuration options from the configuration file path, store them in a ParticipantConfig object and return it.
static ParticipantConfig fromEnvironment (const ParticipantConfig &defaults=ParticipantConfig())
 Obtain configuration options from environment variables, store them in a ParticipantConfig object and return it.
static ParticipantConfig fromConfiguration (const ParticipantConfig &defaults=ParticipantConfig())
 Obtain configuration options from multiple sources, store them in a ParticipantConfig object and return it.

Private Member Functions

void handleOption (const std::vector< std::string > &key, const std::string &value)
void printContents (std::ostream &stream) const

Private Attributes

rsc::logging::LoggerPtr logger
QualityOfServiceSpec qosSpec
ErrorStrategy errorStrategy
std::map< std::string, Transporttransports
EventProcessingStrategy eventReceivingStrategy
EventProcessingStrategy eventSendingStrategy
rsc::runtime::Properties options

Detailed Description

A class describing the configuration of Participant instances.

This contains:

Author
jwienke
jmoringe

Definition at line 61 of file ParticipantConfig.h.

Member Enumeration Documentation

Possible error handling strategies in user-provided code like event handlers.

Author
jwienke
Enumerator:
LOG 

Logs a message using the logging mechanism.

PRINT 

Uses stderr for printing a message.

EXIT 

exits the program.

Definition at line 205 of file ParticipantConfig.h.

Constructor & Destructor Documentation

rsb::ParticipantConfig::ParticipantConfig ( )

Constructs a new empty configuration using the default QoS settings and LOG as error strategy.

Definition at line 181 of file ParticipantConfig.cpp.

rsb::ParticipantConfig::~ParticipantConfig ( )
virtual

Definition at line 188 of file ParticipantConfig.cpp.

Member Function Documentation

void rsb::ParticipantConfig::addTransport ( const Transport transport)

Adds a transport to the list of desired transport mechanisms.

Parameters
transportconfig of the transport

Definition at line 242 of file ParticipantConfig.cpp.

References rsb::ParticipantConfig::Transport::getName(), and transports.

Referenced by rsb::Factory::Factory(), and handleOption().

Here is the call graph for this function:

Here is the caller graph for this function:

ParticipantConfig rsb::ParticipantConfig::fromConfiguration ( const ParticipantConfig defaults = ParticipantConfig())
static

Obtain configuration options from multiple sources, store them in a ParticipantConfig object and return it.

The following sources of configuration information will be consulted:

  1. ~/.config/rsb.conf
  2. $(PWD)/rsb.conf
  3. Environment Variables
Parameters
defaultsA ParticipantConfig object the options of which should be used as defaults.
Returns
A ParticipantConfig object that contains the merged configuration options from the sources mentioned above.
See Also
fromFile, fromEnvironment

Definition at line 307 of file ParticipantConfig.cpp.

References fromEnvironment(), and fromFile().

Referenced by rsb::Factory::Factory().

Here is the call graph for this function:

Here is the caller graph for this function:

ParticipantConfig rsb::ParticipantConfig::fromEnvironment ( const ParticipantConfig defaults = ParticipantConfig())
static

Obtain configuration options from environment variables, store them in a ParticipantConfig object and return it.

Environment variable names are mapped to RSB option names as illustrated in the following example:

RSB_TRANSPORT_SPREAD_PORT -> transport spread port
Parameters
defaultsA ParticipantConfig object that supplies values for configuration options for which no environment variables are found.
Returns
A ParticipantConfig object that contains the merged configuration options from defaults and relevant environment variables.
See Also
fromFile, fromConfiguration

Definition at line 300 of file ParticipantConfig.cpp.

Referenced by fromConfiguration().

Here is the caller graph for this function:

ParticipantConfig rsb::ParticipantConfig::fromFile ( const boost::filesystem::path &  path,
const ParticipantConfig defaults = ParticipantConfig() 
)
static

Obtain configuration options from the configuration file path, store them in a ParticipantConfig object and return it.

A simple configuration file may look like this:

[transport.spread]
host = azurit
port = 5301
# A comment
Parameters
pathThe path of a file from which configuration options should be loaded.
defaultsA ParticipantConfig object that supplies values for configuration options which are not present in path.
Returns
A new ParticipantConfig object reflecting the contents of path possibly merged with options from defaults.
See Also
fromEnvironment, fromConfiguration

Definition at line 282 of file ParticipantConfig.cpp.

References logger.

Referenced by fromConfiguration().

Here is the caller graph for this function:

ParticipantConfig::ErrorStrategy rsb::ParticipantConfig::getErrorStrategy ( ) const

Returns the selected error strategy for the configured participant.

Returns
strategy to use

Definition at line 204 of file ParticipantConfig.cpp.

References errorStrategy.

const ParticipantConfig::EventProcessingStrategy & rsb::ParticipantConfig::getEventReceivingStrategy ( ) const

Definition at line 258 of file ParticipantConfig.cpp.

References eventReceivingStrategy.

const ParticipantConfig::EventProcessingStrategy & rsb::ParticipantConfig::getEventSendingStrategy ( ) const

Definition at line 266 of file ParticipantConfig.cpp.

References eventSendingStrategy.

rsc::runtime::Properties rsb::ParticipantConfig::getOptions ( ) const

Returns additional options besides the transport-specific ones.

Returns
copy of additional options

Definition at line 270 of file ParticipantConfig.cpp.

References options.

Referenced by rsb::ParticipantConfig::Transport::isEnabled(), and rsb::ParticipantConfig::Transport::setEnabled().

Here is the caller graph for this function:

QualityOfServiceSpec rsb::ParticipantConfig::getQualityOfServiceSpec ( ) const

Returns the current settings for QoS.

Returns
quality of service settings as immutable copy

Definition at line 191 of file ParticipantConfig.cpp.

References qosSpec.

ParticipantConfig::Transport rsb::ParticipantConfig::getTransport ( const std::string &  name) const

Returns an immutable copy of a single configured transport.

Parameters
namename of the transport to get
Returns
copy of the transport
Exceptions
rsc::runtime::NoSuchObjectno such transport available with the given name

Definition at line 212 of file ParticipantConfig.cpp.

References transports.

set< ParticipantConfig::Transport > rsb::ParticipantConfig::getTransports ( bool  includeDisabled = false) const

Returns the set of desired transports for a participant.

Parameters
includeDisabledIf true, include transports that have been disabled via configuration options.
Returns
set of transports identified by strings
Note
generates a copy. Changing the returned object does not change this configuration

Definition at line 228 of file ParticipantConfig.cpp.

References logger, and transports.

Referenced by rsb::Factory::createInPullConnectors(), rsb::Factory::createInPushConnectors(), rsb::Factory::createOutConnectors(), rsb::Factory::Factory(), and printContents().

Here is the caller graph for this function:

ParticipantConfig::EventProcessingStrategy & rsb::ParticipantConfig::mutableEventReceivingStrategy ( )

Definition at line 262 of file ParticipantConfig.cpp.

References eventReceivingStrategy.

rsc::runtime::Properties & rsb::ParticipantConfig::mutableOptions ( )

Returns a mutable reference to the freestyle options in this configuration.

Returns
mutable reference to additional options

Definition at line 274 of file ParticipantConfig.cpp.

References options.

QualityOfServiceSpec & rsb::ParticipantConfig::mutableQualityOfServiceSpec ( )

Returns mutable quality of service settings.

Returns
reference to QoS settings

Definition at line 195 of file ParticipantConfig.cpp.

References qosSpec.

ParticipantConfig::Transport & rsb::ParticipantConfig::mutableTransport ( const std::string &  name)

Returns a single configured transport which can be modified in place.

Parameters
namename of the transport to get
Returns
reference to the transport
Exceptions
rsc::runtime::NoSuchObjectno such transport available with the given name

Definition at line 220 of file ParticipantConfig.cpp.

References transports.

Referenced by rsb::Factory::Factory().

Here is the caller graph for this function:

void rsb::ParticipantConfig::printContents ( std::ostream &  stream) const
private

Definition at line 429 of file ParticipantConfig.cpp.

References errorStrategy, eventReceivingStrategy, eventSendingStrategy, getTransports(), options, and qosSpec.

Here is the call graph for this function:

void rsb::ParticipantConfig::removeTransport ( const Transport transport)

Removes a transport from the list of desired transports if it was present.

Parameters
transportto remove

Definition at line 247 of file ParticipantConfig.cpp.

References rsb::ParticipantConfig::Transport::getName(), and transports.

Here is the call graph for this function:

void rsb::ParticipantConfig::setErrorStrategy ( const ErrorStrategy strategy)

Sets the desired error strategy for the participant.

Definition at line 208 of file ParticipantConfig.cpp.

References errorStrategy.

void rsb::ParticipantConfig::setOptions ( const rsc::runtime::Properties &  options)

Sets the additional options besides the transport-specific ones.

Parameters
optionsnew options replacing all old ones

Definition at line 278 of file ParticipantConfig.cpp.

References options.

Referenced by rsb::ParticipantConfig::Transport::setEnabled().

Here is the caller graph for this function:

void rsb::ParticipantConfig::setQualityOfServiceSpec ( const QualityOfServiceSpec spec)

Sets the desired QoS settings.

Parameters
specnew settings

Definition at line 199 of file ParticipantConfig.cpp.

References qosSpec.

void rsb::ParticipantConfig::setTransports ( const std::set< Transport > &  transports)

Sets all desired transports in this configuration.

Parameters
transportsset of transports

Definition at line 251 of file ParticipantConfig.cpp.

Member Data Documentation

ErrorStrategy rsb::ParticipantConfig::errorStrategy
private
EventProcessingStrategy rsb::ParticipantConfig::eventReceivingStrategy
private
EventProcessingStrategy rsb::ParticipantConfig::eventSendingStrategy
private

Definition at line 416 of file ParticipantConfig.h.

Referenced by getEventSendingStrategy(), handleOption(), and printContents().

rsc::logging::LoggerPtr rsb::ParticipantConfig::logger
private

Definition at line 410 of file ParticipantConfig.h.

Referenced by fromFile(), and getTransports().

QualityOfServiceSpec rsb::ParticipantConfig::qosSpec
private
std::map<std::string, Transport> rsb::ParticipantConfig::transports
private

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