32 #include <boost/format.hpp> 33 #include <boost/filesystem/fstream.hpp> 35 #include <rsc/logging/Logger.h> 39 using namespace boost;
48 ParticipantConfig::Transport::Transport(
const string& name,
52 throw invalid_argument(
53 "The name of a transport configuration cannot be empty.");
85 return this->
getOptions().getAs<
bool> (
"enabled",
true);
90 options[
"enabled"] = lexical_cast<
string>(value);
95 const string& value) {
97 && (key[0] ==
"converter")
98 && (key[1] ==
"cpp")) {
99 if (key.size() != 3) {
100 throw invalid_argument(
103 "Option key `%1%' has invalid number of components; converter-related keys for transports has to have three components")
106 this->
converters.insert(make_pair(key[2], value));
107 }
else if ((key.size() >= 2) && (key[0] ==
"converter")) {
110 if (key.size() != 1) {
111 throw invalid_argument(
114 "Key `%1%' has invalid number of components; transport option keys have to have one component.")
134 stream <<
"name = " << this->
name 136 <<
", options = " << this->
options;
164 const string& value) {
165 if (key.size() != 1) {
166 throw invalid_argument(str(format(
"Key `%1%' has invalid number of components; transport option keys have to have one component.")
170 this->
options.set<
string>(key.front(), value);
174 stream <<
"name = " << this->
name 175 <<
", options = " << this->
options;
179 logger(Logger::getLogger(
"rsb.ParticipantConfig")),
211 map<string, Transport>::const_iterator it = this->
transports.find(name);
213 throw rsc::runtime::NoSuchObject(name);
219 map<string, Transport>::iterator it = this->
transports.find(name);
221 throw rsc::runtime::NoSuchObject(name);
227 bool includeDisabled)
const {
228 set<Transport> result;
229 for (map<string, Transport>::const_iterator it = this->
transports.begin(); it
231 if (it->second.isEnabled() || includeDisabled) {
232 result.insert(it->second);
234 RSCDEBUG(
logger,
"Skipping disabled transport " << it->second);
250 this->transports.clear();
251 for (set<Transport>::const_iterator it = transports.begin(); it
252 != transports.end(); ++it) {
253 this->transports.insert(make_pair(it->getName(), *it));
291 const string& value) {
293 if (key[0] ==
"qualityofservice") {
294 if (key.size() != 2) {
295 throw invalid_argument(
298 "Option key `%1%' has invalid number of components; options related to quality of service have to have two components.")
301 if (key[1] ==
"reliability") {
302 if (value ==
"UNRELIABLE") {
304 }
else if (value ==
"RELIABLE") {
307 throw invalid_argument(str(format(
308 "The value `%1%' is invalid for the key `%2%'.")
310 }
else if (key[1] ==
"ordering") {
311 if (value ==
"UNORDERED") {
313 }
else if (value ==
"ORDERED") {
316 throw invalid_argument(str(format(
317 "The value `%1%' is invalid for the key `%2%'.")
321 }
else if (key[0] ==
"errorhandling") {
322 if (key[1] ==
"onhandlererror") {
323 if (value ==
"LOG") {
325 }
else if (value ==
"PRINT") {
327 }
else if (value ==
"EXIT") {
330 throw invalid_argument(str(format(
331 "The value `%1%' is invalid for the key `%2%'.")
336 }
else if (key[0] ==
"eventprocessing") {
338 if (key[1] ==
"receivingstrategy") {
340 }
else if (key[1] ==
"sendingstrategy") {
343 throw invalid_argument(
344 str(format(
"`%2%' is not a valid sub-key of `%1%'.")
347 if (key.size() == 2) {
350 vector<string> subKey;
351 copy(key.begin() + 2, key.end(), back_inserter(subKey));
356 }
else if (key[0] ==
"introspection") {
357 if ((key.size() == 2) && (key[1] ==
"enabled")) {
362 }
else if (key[0] ==
"transport") {
363 if (key.size() < 3) {
364 throw invalid_argument(
367 "Option key `%1%' has invalid number of components; transport-related keys have to have at least three components.")
370 map<string, Transport>::iterator it = this->
transports.find(key[1]);
376 vector<string> subKey;
377 copy(key.begin() + 2, key.end(), back_inserter(subKey));
381 if (key.size() == 1) {
388 stream <<
"qosSpec = " << this->
qosSpec 393 <<
", options = " << this->
options;
void setOptions(const rsc::runtime::Properties &options)
Sets the additional options besides the transport-specific ones.
Specification of desired quality of service settings for sending and receiving events.
void setQualityOfServiceSpec(const QualityOfServiceSpec &spec)
Sets the desired QoS settings.
QualityOfServiceSpec qosSpec
Uses stderr for printing a message.
rsc::runtime::Properties getOptions() const
Returns the specified options for the transport.
rsc::runtime::Properties getOptions() const
Returns additional options besides the transport-specific ones.
ErrorStrategy errorStrategy
rsc::runtime::Properties & mutableOptions()
Returns the options for the transport.
bool operator==(const Transport &other) const
Every listener receives the events of one informer in the order the informer sent the events...
void handleOption(const std::vector< std::string > &key, const std::string &value)
QualityOfServiceSpec & mutableQualityOfServiceSpec()
Returns mutable quality of service settings.
EventProcessingStrategy eventSendingStrategy
ErrorStrategy getErrorStrategy() const
Returns the selected error strategy for the configured participant.
std::string getName() const
Returns the name of the implementation to be selected.
std::string getName() const
Returns the name of this transport description.
EventProcessingStrategy eventReceivingStrategy
std::string getClassName() const
rsc::runtime::Properties getOptions() const
Returns the options for the strategy.
void handleOption(const std::vector< std::string > &key, const std::string &value)
rsc::logging::LoggerPtr logger
void printContents(std::ostream &stream) const
Events may be dropped and not be visible to a listener.
void addTransport(const Transport &transport)
Adds a transport to the list of desired transport mechanisms.
ConverterNames getConverters() const
void setName(const std::string &name)
Sets the name of the implementation to be selected.
rsc::runtime::Properties options
EventProcessingStrategy(const std::string &name)
EventProcessingStrategy & mutableEventReceivingStrategy()
void setOptions(const rsc::runtime::Properties &options)
Sets the options for the strategy.
rsc::runtime::Properties options
bool isIntrospectionEnabled() const
Indicates whether introspection should be enabled for the participant.
rsc::runtime::Properties & mutableOptions()
Returns the options for the strategy.
const EventProcessingStrategy & getEventReceivingStrategy() const
ConverterNames converters
Description of a desired transport.
rsc::runtime::Properties & mutableOptions()
Returns a mutable reference to the freestyle options in this configuration.
bool operator<(const Transport &other) const
void removeTransport(const Transport &transport)
Removes a transport from the list of desired transports if it was present.
void printContents(std::ostream &stream) const
void setTransports(const std::set< Transport > &transports)
Replaces all existing transports with the ones given here.
The events are delivered in arbitrary order.
ErrorStrategy
Possible error handling strategies in user-provided code like event handlers.
virtual ~ParticipantConfig()
Logs a message using the logging mechanism.
QualityOfServiceSpec getQualityOfServiceSpec() const
Returns the current settings for QoS.
Transport & mutableTransport(const std::string &name)
Returns a single configured transport which can be modified in place.
Instances of this class describe the selection and configuration of an event processing strategy...
void setIsIntrospectionEnabled(bool newValue)
Controls whether introspection should be enabled for the participant.
void setErrorStrategy(const ErrorStrategy &strategy)
Sets the desired error strategy for the participant.
void handleOption(const std::vector< std::string > &key, const std::string &value)
const EventProcessingStrategy & getEventSendingStrategy() const
std::map< std::string, Transport > transports
ParticipantConfig()
Constructs a new empty configuration using the default QoS settings and #LOG as error strategy...
std::set< Transport > getTransports(bool includeDisabled=false) const
Returns the set of desired transports for a participant.
std::set< std::pair< std::string, std::string > > ConverterNames
Messages are guaranteed to be delivered.
void setOptions(const rsc::runtime::Properties &options)
Sets the options for the transport.
void printContents(std::ostream &stream) const
void setEnabled(bool value)
rsc::runtime::Properties options
Transport getTransport(const std::string &name) const
Returns an immutable copy of a single configured transport.