32 #include <boost/format.hpp>
33 #include <boost/filesystem/fstream.hpp>
35 #include <rsc/config/TypedValue.h>
36 #include <rsc/logging/Logger.h>
40 using namespace boost;
41 using namespace boost::filesystem;
43 using namespace rsc::config;
44 using namespace rsc::logging;
45 using namespace rsc::runtime;
49 ParticipantConfig::Transport::Transport(
const string& name,
53 throw invalid_argument(
54 "The name of a transport configuration cannot be empty.");
69 return this->converters;
86 return this->
getOptions().getAs<
bool> (
"enabled",
true);
91 options[
"enabled"] = lexical_cast<
string>(value);
96 const string& value) {
98 && (key[0] ==
"converter")
99 && (key[1] ==
"cpp")) {
100 if (key.size() != 3) {
101 throw invalid_argument(
104 "Option key `%1%' has invalid number of components; converter-related keys for transports has to have three components")
107 this->converters.insert(make_pair(key[2], value));
108 }
else if ((key.size() >= 2) && (key[0] ==
"converter")) {
111 if (key.size() != 1) {
112 throw invalid_argument(
115 "Key `%1%' has invalid number of components; transport option keys have to have one component.")
123 return name == other.
name;
127 return name < other.
name;
135 stream <<
"name = " << this->name
136 <<
", converters = " << this->converters
137 <<
", options = " << this->
options;
165 const string& value) {
166 if (key.size() != 1) {
167 throw invalid_argument(str(format(
"Key `%1%' has invalid number of components; transport option keys have to have one component.")
171 this->
options.set<
string>(key.front(), value);
175 stream <<
"name = " << this->name
176 <<
", options = " << this->
options;
180 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));
281 const string& value) {
283 if (key[0] ==
"qualityofservice") {
284 if (key.size() != 2) {
285 throw invalid_argument(
288 "Option key `%1%' has invalid number of components; options related to quality of service have to have two components.")
291 if (key[1] ==
"reliability") {
292 if (value ==
"UNRELIABLE") {
294 }
else if (value ==
"RELIABLE") {
297 throw invalid_argument(str(format(
298 "The value `%1%' is invalid for the key `%2%'.")
300 }
else if (key[1] ==
"ordering") {
301 if (value ==
"UNORDERED") {
303 }
else if (value ==
"ORDERED") {
306 throw invalid_argument(str(format(
307 "The value `%1%' is invalid for the key `%2%'.")
310 throw invalid_argument(
311 str(format(
"`%2%' is not a valid sub-key of `%1%'.")
315 }
else if (key[0] ==
"errorhandling") {
316 if (key[1] ==
"onhandlererror") {
317 if (value ==
"LOG") {
319 }
else if (value ==
"PRINT") {
321 }
else if (value ==
"EXIT") {
324 throw invalid_argument(str(format(
325 "The value `%1%' is invalid for the key `%2%'.")
329 throw invalid_argument(
330 str(format(
"`%2%' is not a valid sub-key of `%1%'.")
334 }
else if (key[0] ==
"eventprocessing") {
336 if (key[1] ==
"receivingstrategy") {
338 }
else if (key[1] ==
"sendingstrategy") {
341 throw invalid_argument(
342 str(format(
"`%2%' is not a valid sub-key of `%1%'.")
345 if (key.size() == 2) {
348 vector<string> subKey;
349 copy(key.begin() + 2, key.end(), back_inserter(subKey));
353 }
else if (key[0] ==
"transport") {
354 if (key.size() < 3) {
355 throw invalid_argument(
358 "Option key `%1%' has invalid number of components; transport-related keys have to have at least three components.")
361 map<string, Transport>::iterator it = this->
transports.find(key[1]);
367 vector<string> subKey;
368 copy(key.begin() + 2, key.end(), back_inserter(subKey));
372 if (key.size() == 1) {
373 this->
options[key[0]] = parseTypedValue(value);
379 stream <<
"qosSpec = " << this->
qosSpec
384 <<
", options = " << this->
options <<
"]";