32 #include <boost/format.hpp>
33 #include <boost/filesystem/fstream.hpp>
35 #include <rsc/logging/Logger.h>
39 using namespace boost;
40 using namespace boost::filesystem;
42 using namespace rsc::config;
43 using namespace rsc::logging;
44 using namespace rsc::runtime;
48 ParticipantConfig::Transport::Transport(
const string& name,
52 throw invalid_argument(
53 "The name of a transport configuration cannot be empty.");
68 return this->converters;
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.")
122 return name == other.
name;
126 return name < other.
name;
134 stream <<
"name = " << this->name
135 <<
", converters = " << this->converters
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 for (set<Transport>::const_iterator it = transports.begin(); it
251 != transports.end(); ++it) {
252 this->transports.insert(make_pair(it->getName(), *it));
290 const string& value) {
292 if (key[0] ==
"qualityofservice") {
293 if (key.size() != 2) {
294 throw invalid_argument(
297 "Option key `%1%' has invalid number of components; options related to quality of service have to have two components.")
300 if (key[1] ==
"reliability") {
301 if (value ==
"UNRELIABLE") {
303 }
else if (value ==
"RELIABLE") {
306 throw invalid_argument(str(format(
307 "The value `%1%' is invalid for the key `%2%'.")
309 }
else if (key[1] ==
"ordering") {
310 if (value ==
"UNORDERED") {
312 }
else if (value ==
"ORDERED") {
315 throw invalid_argument(str(format(
316 "The value `%1%' is invalid for the key `%2%'.")
320 }
else if (key[0] ==
"errorhandling") {
321 if (key[1] ==
"onhandlererror") {
322 if (value ==
"LOG") {
324 }
else if (value ==
"PRINT") {
326 }
else if (value ==
"EXIT") {
329 throw invalid_argument(str(format(
330 "The value `%1%' is invalid for the key `%2%'.")
335 }
else if (key[0] ==
"eventprocessing") {
337 if (key[1] ==
"receivingstrategy") {
339 }
else if (key[1] ==
"sendingstrategy") {
342 throw invalid_argument(
343 str(format(
"`%2%' is not a valid sub-key of `%1%'.")
346 if (key.size() == 2) {
349 vector<string> subKey;
350 copy(key.begin() + 2, key.end(), back_inserter(subKey));
355 }
else if (key[0] ==
"introspection") {
356 if ((key.size() == 2) && (key[1] ==
"enabled")) {
361 }
else if (key[0] ==
"transport") {
362 if (key.size() < 3) {
363 throw invalid_argument(
366 "Option key `%1%' has invalid number of components; transport-related keys have to have at least three components.")
369 map<string, Transport>::iterator it = this->
transports.find(key[1]);
375 vector<string> subKey;
376 copy(key.begin() + 2, key.end(), back_inserter(subKey));
380 if (key.size() == 1) {
387 stream <<
"qosSpec = " << this->
qosSpec
392 <<
", 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.
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
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)
Sets all desired transports in this configuration.
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)
Transport getTransport(const std::string &name) const
Returns an immutable copy of a single configured transport.