RSB  0.12.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 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 
65  if (!this->listener) {
66  this->listener = makeListener();
67  }
68 
69  return this->listener;
70 }
71 
73  return this->listenerConfig;
74 }
75 
78  shared_from_this());
79 }
80 
82  if (!this->informer) {
83  this->informer = makeInformer();
84  }
85 
86  return this->informer;
87 }
88 
90  return this->informerConfig;
91 }
92 
95  "", // TODO
97  shared_from_this());
98 }
99 
100 }
101 }
ListenerPtr listener
Definition: Server.h:114
virtual InformerBasePtr makeInformer()
Creates and returns the Informer participant.
Definition: Server.cpp:93
Method(const Scope &scope, const std::string &name, const ParticipantConfig &listenerConfig, const ParticipantConfig &informerConfig)
Definition: Server.cpp:34
Objects of this class participate in the exchange of notifications on one channel of the bus...
Definition: Participant.h:64
const std::string & getName() const
Returns the name of the method.
Definition: Server.cpp:59
InformerBasePtr informer
Definition: Server.h:115
ParticipantConfig listenerConfig
Definition: Server.h:111
const ParticipantConfig & getInformerConfig() const
Returns the configuration for the Informer participant.
Definition: Server.cpp:89
ListenerPtr createListener(const Scope &scope, const ParticipantConfig &config=getFactory().getDefaultParticipantConfig(), ParticipantPtr parent=ParticipantPtr())
Creates a new listener for the specified scope.
Definition: Factory.cpp:278
Factory & getFactory()
Returns a factory for client-level RSB objects.
Definition: Factory.cpp:159
boost::shared_ptr< Listener > ListenerPtr
Definition: Listener.h:151
const ParticipantConfig & getListenerConfig() const
Returns the configuration for the Listener participant.
Definition: Server.cpp:72
InformerBasePtr getInformer()
Returns the Informer participant, creating it if necessary.
Definition: Server.cpp:81
virtual ListenerPtr makeListener()
Creates and returns the Listener participant.
Definition: Server.cpp:76
std::string name
Definition: Server.h:109
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:266
ParticipantConfig informerConfig
Definition: Server.h:112
A class describing the configuration of Participant instances.
boost::shared_ptr< InformerBase > InformerBasePtr
Definition: Informer.h:214
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:64