RSB
0.7.0
|
A class describing the configuration of Participant instances. More...
#include <ParticipantConfig.h>
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. | |
QualityOfServiceSpec & | mutableQualityOfServiceSpec () |
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< Transport > | getTransports (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. | |
Transport & | mutableTransport (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 EventProcessingStrategy & | getEventReceivingStrategy () const |
EventProcessingStrategy & | mutableEventReceivingStrategy () |
const EventProcessingStrategy & | getEventSendingStrategy () 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, Transport > | transports |
EventProcessingStrategy | eventReceivingStrategy |
EventProcessingStrategy | eventSendingStrategy |
rsc::runtime::Properties | options |
A class describing the configuration of Participant instances.
This contains:
Definition at line 61 of file ParticipantConfig.h.
Possible error handling strategies in user-provided code like event handlers.
LOG |
Logs a message using the logging mechanism. |
Uses stderr for printing a message. | |
EXIT |
exits the program. |
Definition at line 205 of file ParticipantConfig.h.
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.
|
virtual |
Definition at line 188 of file ParticipantConfig.cpp.
void rsb::ParticipantConfig::addTransport | ( | const Transport & | transport | ) |
Adds a transport to the list of desired transport mechanisms.
transport | config 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().
|
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:
defaults | A ParticipantConfig object the options of which should be used as defaults. |
Definition at line 307 of file ParticipantConfig.cpp.
References fromEnvironment(), and fromFile().
Referenced by rsb::Factory::Factory().
|
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
defaults | A ParticipantConfig object that supplies values for configuration options for which no environment variables are found. |
Definition at line 300 of file ParticipantConfig.cpp.
Referenced by fromConfiguration().
|
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
path | The path of a file from which configuration options should be loaded. |
defaults | A ParticipantConfig object that supplies values for configuration options which are not present in path. |
Definition at line 282 of file ParticipantConfig.cpp.
References logger.
Referenced by fromConfiguration().
ParticipantConfig::ErrorStrategy rsb::ParticipantConfig::getErrorStrategy | ( | ) | const |
Returns the selected error strategy for the configured participant.
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.
Definition at line 270 of file ParticipantConfig.cpp.
References options.
Referenced by rsb::ParticipantConfig::Transport::isEnabled(), and rsb::ParticipantConfig::Transport::setEnabled().
QualityOfServiceSpec rsb::ParticipantConfig::getQualityOfServiceSpec | ( | ) | const |
Returns the current settings for QoS.
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.
name | name of the transport to get |
rsc::runtime::NoSuchObject | no 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.
includeDisabled | If true, include transports that have been disabled via configuration options. |
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().
|
private |
Definition at line 331 of file ParticipantConfig.cpp.
References addTransport(), errorStrategy, eventReceivingStrategy, eventSendingStrategy, EXIT, rsb::ParticipantConfig::Transport::handleOption(), rsb::ParticipantConfig::EventProcessingStrategy::handleOption(), LOG, options, rsb::QualityOfServiceSpec::ORDERED, rsb::QualityOfServiceSpec::ordering, PRINT, qosSpec, rsb::QualityOfServiceSpec::reliability, rsb::QualityOfServiceSpec::RELIABLE, rsb::ParticipantConfig::EventProcessingStrategy::setName(), transports, rsb::QualityOfServiceSpec::UNORDERED, and rsb::QualityOfServiceSpec::UNRELIABLE.
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.
Definition at line 274 of file ParticipantConfig.cpp.
References options.
QualityOfServiceSpec & rsb::ParticipantConfig::mutableQualityOfServiceSpec | ( | ) |
Returns mutable quality of service 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.
name | name of the transport to get |
rsc::runtime::NoSuchObject | no such transport available with the given name |
Definition at line 220 of file ParticipantConfig.cpp.
References transports.
Referenced by rsb::Factory::Factory().
|
private |
Definition at line 429 of file ParticipantConfig.cpp.
References errorStrategy, eventReceivingStrategy, eventSendingStrategy, getTransports(), options, and qosSpec.
void rsb::ParticipantConfig::removeTransport | ( | const Transport & | transport | ) |
Removes a transport from the list of desired transports if it was present.
transport | to remove |
Definition at line 247 of file ParticipantConfig.cpp.
References rsb::ParticipantConfig::Transport::getName(), and transports.
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.
options | new options replacing all old ones |
Definition at line 278 of file ParticipantConfig.cpp.
References options.
Referenced by rsb::ParticipantConfig::Transport::setEnabled().
void rsb::ParticipantConfig::setQualityOfServiceSpec | ( | const QualityOfServiceSpec & | spec | ) |
Sets the desired QoS settings.
spec | new 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.
transports | set of transports |
Definition at line 251 of file ParticipantConfig.cpp.
|
private |
Definition at line 413 of file ParticipantConfig.h.
Referenced by getErrorStrategy(), handleOption(), printContents(), and setErrorStrategy().
|
private |
Definition at line 415 of file ParticipantConfig.h.
Referenced by getEventReceivingStrategy(), handleOption(), mutableEventReceivingStrategy(), and printContents().
|
private |
Definition at line 416 of file ParticipantConfig.h.
Referenced by getEventSendingStrategy(), handleOption(), and printContents().
|
private |
Definition at line 410 of file ParticipantConfig.h.
Referenced by fromFile(), and getTransports().
|
private |
Definition at line 417 of file ParticipantConfig.h.
Referenced by rsb::ParticipantConfig::Transport::getOptions(), rsb::ParticipantConfig::EventProcessingStrategy::getOptions(), getOptions(), rsb::ParticipantConfig::Transport::handleOption(), rsb::ParticipantConfig::EventProcessingStrategy::handleOption(), handleOption(), rsb::ParticipantConfig::Transport::mutableOptions(), rsb::ParticipantConfig::EventProcessingStrategy::mutableOptions(), mutableOptions(), rsb::ParticipantConfig::Transport::printContents(), rsb::ParticipantConfig::EventProcessingStrategy::printContents(), printContents(), rsb::ParticipantConfig::Transport::setEnabled(), rsb::ParticipantConfig::Transport::setOptions(), rsb::ParticipantConfig::EventProcessingStrategy::setOptions(), and setOptions().
|
private |
Definition at line 412 of file ParticipantConfig.h.
Referenced by getQualityOfServiceSpec(), handleOption(), mutableQualityOfServiceSpec(), printContents(), and setQualityOfServiceSpec().
|
private |
Definition at line 414 of file ParticipantConfig.h.
Referenced by addTransport(), getTransport(), getTransports(), handleOption(), mutableTransport(), and removeTransport().