RSB  0.17.0
Server.cpp
Go to the documentation of this file.
1 /* ============================================================
2  *
3  * This file is part of the RSB project.
4  *
5  * Copyright (C) 2014, 2015 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 
27 #include "Server.h"
28 
29 #include "../Factory.h"
30 
31 namespace rsb {
32 namespace patterns {
33 
34 Method::Method(const Scope& scope,
35  const std::string& name,
36  const ParticipantConfig& listenerConfig,
37  const ParticipantConfig& informerConfig)
38  : Participant(scope, listenerConfig), name(name), // TODO do config properly
39  listenerConfig(listenerConfig), informerConfig(informerConfig) {
40 }
41 
43  deactivate();
44 }
45 
47  getListener(); // Force listener creation
48 }
49 
51  if (this->listener) {
52  this->listener.reset();
53  }
54  if (this->informer) {
55  this->informer.reset();
56  }
57 }
58 
59 const std::string& Method::getName() const {
60  return this->name;
61 }
62 
63 const std::set<std::string> Method::getTransportURLs() const {
64  return std::set<std::string>();
65 }
66 
67 
69  if (!this->listener) {
70  this->listener = makeListener();
71  }
72 
73  return this->listener;
74 }
75 
77  return this->listenerConfig;
78 }
79 
82  shared_from_this());
83 }
84 
86  if (!this->informer) {
87  this->informer = makeInformer();
88  }
89 
90  return this->informer;
91 }
92 
94  return this->informerConfig;
95 }
96 
99  "", // TODO
101  shared_from_this());
102 }
103 
104 }
105 }
ListenerPtr listener
Definition: Server.h:120
virtual InformerBasePtr makeInformer()
Creates and returns the Informer participant.
Definition: Server.cpp:97
Method(const Scope &scope, const std::string &name, const ParticipantConfig &listenerConfig, const ParticipantConfig &informerConfig)
Definition: Server.cpp:34
virtual const std::set< std::string > getTransportURLs() const
TODO.
Definition: Server.cpp:63
Objects of this class participate in the exchange of notifications on one channel of the bus...
Definition: Participant.h:65
const std::string & getName() const
Returns the name of the method.
Definition: Server.cpp:59
InformerBasePtr informer
Definition: Server.h:121
ParticipantConfig listenerConfig
Definition: Server.h:117
const ParticipantConfig & getInformerConfig() const
Returns the configuration for the Informer participant.
Definition: Server.cpp:93
ListenerPtr createListener(const Scope &scope, const ParticipantConfig &config=getFactory().getDefaultParticipantConfig(), ParticipantPtr parent=ParticipantPtr())
Creates a new listener for the specified scope.
Definition: Factory.cpp:327
Factory & getFactory()
Returns a factory for client-level RSB objects.
Definition: Factory.cpp:163
boost::shared_ptr< Listener > ListenerPtr
Definition: Listener.h:155
const ParticipantConfig & getListenerConfig() const
Returns the configuration for the Listener participant.
Definition: Server.cpp:76
InformerBasePtr getInformer()
Returns the Informer participant, creating it if necessary.
Definition: Server.cpp:85
virtual ListenerPtr makeListener()
Creates and returns the Listener participant.
Definition: Server.cpp:80
std::string name
Definition: Server.h:115
InformerBasePtr createInformerBase(const Scope &scope, const std::string &dataType="", const ParticipantConfig &config=getFactory().getDefaultParticipantConfig(), ParticipantPtr parent=ParticipantPtr())
Creates and returns a new Informer that publishes Event s under the Scope scope.
Definition: Factory.cpp:315
ParticipantConfig informerConfig
Definition: Server.h:118
A class describing the configuration of Participant instances.
boost::shared_ptr< InformerBase > InformerBasePtr
Definition: Informer.h:217
ScopePtr getScope() const
Returns the scope of this participant.
Definition: Participant.cpp:64
virtual ~Method()
Definition: Server.cpp:42
Scope is a descriptor for a hierarchical channel of the unified bus.
Definition: Scope.h:46
ListenerPtr getListener()
Returns the Listener participant, creating it if necessary.
Definition: Server.cpp:68