RSB  0.7.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
PushInRouteConfigurator.cpp
Go to the documentation of this file.
1 /* ============================================================
2  *
3  * This file is part of the RSB project
4  *
5  * Copyright (C) 2011 Jan Moringen <jmoringe@techfak.uni-bielefeld.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 
28 
29 #include <boost/bind.hpp>
30 
32 
33 using namespace std;
34 
35 using namespace boost;
36 
37 using namespace rsc::runtime;
38 using namespace rsc::logging;
39 
40 using namespace rsb::transport;
41 
42 namespace rsb {
43 namespace eventprocessing {
44 
45 PushInRouteConfigurator::PushInRouteConfigurator(const Scope& scope,
46  const ParticipantConfig& config) :
47  InRouteConfigurator(scope, config),
48  logger(Logger::getLogger("rsb.eventprocessing.PushInRouteConfigurator")),
49  errorStrategy(ParticipantConfig::LOG) {
50 }
51 
53 }
54 
56  return "PushInRouteConfigurator";
57 }
58 
59 void PushInRouteConfigurator::printContents(ostream& stream) const {
61  stream << ", errorStrategy = " << this->errorStrategy;
62 }
63 
66 
67  // The base class has instantiated an
68  // EventReceivingStrategy. Retrieve it and install our error
69  // handling strategy.
71  = dynamic_pointer_cast<PushEventReceivingStrategy>(getEventReceivingStrategy());
72  this->eventReceivingStrategy->setHandlerErrorStrategy(this->errorStrategy);
73 
74  // Retrieve the set of connectors and ourselves to the list of
75  // handlers of each connector.
77  for (InRouteConfigurator::ConnectorSet::const_iterator it =
78  connectors.begin(); it != connectors.end(); ++it) {
79  InPushConnectorPtr connector = dynamic_pointer_cast<InPushConnector>(
80  *it);
81  assert(connector);
82  connector->addHandler(
83  HandlerPtr(
86  this->eventReceivingStrategy, _1))));
87  }
88 }
89 
90 void PushInRouteConfigurator::handlerAdded(rsb::HandlerPtr handler, const bool& wait) {
91  this->eventReceivingStrategy->addHandler(handler, wait);
92 }
93 
95  this->eventReceivingStrategy->removeHandler(handler, wait);
96 }
97 
99  if (this->eventReceivingStrategy) {
100  this->eventReceivingStrategy->setHandlerErrorStrategy(strategy);
101  }
102  this->errorStrategy = strategy;
103 }
104 
106  string impl = getReceivingStrategyConfig().getName();
107  Properties options = getReceivingStrategyConfig().getOptions();
108  RSCDEBUG(logger, "Instantiating event receiving strategy with config "
110  return EventReceivingStrategyPtr(getEventReceivingStrategyFactory().createInst(impl, options));
111 }
112 
113 }
114 }