RSB  0.9.6
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ParticipantConfig.h
Go to the documentation of this file.
1 /* ============================================================
2  *
3  * This file is a part of the RSB project.
4  *
5  * Copyright (C) 2011 by Johannes Wienke <jwienke at techfak dot uni-bielefeld dot de>
6  *
7  * This file may be licensed under the terms of the
8  * GNU Lesser General Public License Version 3 (the ``LGPL''),
9  * or (at your option) any later version.
10  *
11  * Software distributed under the License is distributed
12  * on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either
13  * express or implied. See the LGPL for the specific language
14  * governing rights and limitations.
15  *
16  * You should have received a copy of the LGPL along with this
17  * program. If not, go to http://www.gnu.org/licenses/lgpl.html
18  * or write to the Free Software Foundation, Inc.,
19  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20  *
21  * The development of this software was supported by:
22  * CoR-Lab, Research Institute for Cognition and Robotics
23  * Bielefeld University
24  *
25  * ============================================================ */
26 
27 #pragma once
28 
29 #include <set>
30 #include <string>
31 #include <ostream>
32 
33 #include <boost/operators.hpp>
34 #include <boost/filesystem/path.hpp>
35 
36 #include <rsc/logging/Logger.h>
37 #include <rsc/config/OptionHandler.h>
38 #include <rsc/runtime/Properties.h>
39 #include <rsc/runtime/Printable.h>
40 
41 #include "QualityOfServiceSpec.h"
42 #include "rsb/rsbexports.h"
43 
44 namespace rsb {
45 
61 class RSB_EXPORT ParticipantConfig: public rsc::config::OptionHandler,
62  public rsc::runtime::Printable {
63 public:
64 
72  class RSB_EXPORT Transport: boost::totally_ordered<Transport>,
73  public rsc::config::OptionHandler,
74  public rsc::runtime::Printable {
75  public:
76  typedef std::set<std::pair<std::string, std::string> > ConverterNames;
77 
88  explicit Transport(const std::string& name,
89  bool enabled = true);
90  virtual ~Transport();
91 
95  std::string getName() const;
96 
97  ConverterNames getConverters() const;
98 
104  rsc::runtime::Properties getOptions() const;
105 
111  rsc::runtime::Properties& mutableOptions();
112 
118  void setOptions(const rsc::runtime::Properties& options);
119 
120  bool isEnabled() const;
121 
122  void setEnabled(bool value);
123 
124  bool operator==(const Transport& other) const;
125  bool operator<(const Transport& other) const;
126 
127  std::string getClassName() const;
128  void printContents(std::ostream& stream) const;
129 
130  void handleOption(const std::vector<std::string>& key,
131  const std::string& value);
132  private:
133  std::string name;
135  rsc::runtime::Properties options;
136  };
137 
148  class RSB_EXPORT EventProcessingStrategy : public rsc::config::OptionHandler,
149  public rsc::runtime::Printable {
150  public:
151  EventProcessingStrategy(const std::string& name);
152 
159  std::string getName() const;
160 
167  void setName(const std::string& name);
168 
174  rsc::runtime::Properties getOptions() const;
175 
181  rsc::runtime::Properties& mutableOptions();
182 
188  void setOptions(const rsc::runtime::Properties& options);
189 
190  void handleOption(const std::vector<std::string>& key,
191  const std::string& value);
192 
193  void printContents(std::ostream& stream) const;
194  private:
195  std::string name;
196  rsc::runtime::Properties options;
197  };
198 
217  ERROR_STRATEGY_EXIT
218  };
219 
225  virtual ~ParticipantConfig();
226 
232  QualityOfServiceSpec getQualityOfServiceSpec() const;
233 
239  QualityOfServiceSpec& mutableQualityOfServiceSpec();
240 
246  void setQualityOfServiceSpec(const QualityOfServiceSpec& spec);
247 
253  ErrorStrategy getErrorStrategy() const;
254 
258  void setErrorStrategy(const ErrorStrategy& strategy);
259 
269  std::set<Transport> getTransports(bool includeDisabled = false) const;
270 
279  Transport getTransport(const std::string& name) const;
280 
289  Transport& mutableTransport(const std::string& name);
290 
296  void addTransport(const Transport& transport);
297 
304  void removeTransport(const Transport& transport);
305 
311  void setTransports(const std::set<Transport>& transports);
312 
313  const EventProcessingStrategy& getEventReceivingStrategy() const;
314 
315  EventProcessingStrategy& mutableEventReceivingStrategy();
316 
317 
318  const EventProcessingStrategy& getEventSendingStrategy() const;
319 
325  rsc::runtime::Properties getOptions() const;
326 
333  rsc::runtime::Properties& mutableOptions();
334 
340  void setOptions(const rsc::runtime::Properties& options);
341 private:
342  rsc::logging::LoggerPtr logger;
343 
346  std::map<std::string, Transport> transports;
349  rsc::runtime::Properties options;
350 
351  void handleOption(const std::vector<std::string>& key,
352  const std::string& value);
353 
354  void printContents(std::ostream& stream) const;
355 };
356 
357 }
Specification of desired quality of service settings for sending and receiving events.
QualityOfServiceSpec qosSpec
Uses stderr for printing a message.
EventProcessingStrategy eventSendingStrategy
EventProcessingStrategy eventReceivingStrategy
rsc::logging::LoggerPtr logger
rsc::runtime::Properties options
rsc::runtime::Properties options
Description of a desired transport.
ErrorStrategy
Possible error handling strategies in user-provided code like event handlers.
Logs a message using the logging mechanism.
Instances of this class describe the selection and configuration of an event processing strategy...
A class describing the configuration of Participant instances.
std::map< std::string, Transport > transports
std::set< std::pair< std::string, std::string > > ConverterNames