RSB  0.14.2
Event.h
Go to the documentation of this file.
1 /* ============================================================
2  *
3  * This file is a part of the RSB project
4  *
5  * Copyright (C) 2010 by Sebastian Wrede <swrede 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 <map>
30 #include <set>
31 #include <string>
32 #include <vector>
33 
34 #include <boost/cstdint.hpp>
35 #include <boost/shared_ptr.hpp>
36 #include <boost/scoped_ptr.hpp>
37 
38 #include <rsc/misc/langutils.h>
39 #include <rsc/misc/UUID.h>
40 #include <rsc/runtime/Printable.h>
41 
42 #include "rsb/rsbexports.h"
43 
44 namespace rsb {
45 
46 class EventId;
47 typedef boost::shared_ptr<EventId> EventIdPtr;
48 class MetaData;
49 class Scope;
50 typedef boost::shared_ptr<Scope> ScopePtr;
51 
52 typedef boost::shared_ptr<void> VoidPtr;
53 
61 class RSB_EXPORT Event: public virtual rsc::runtime::Printable {
62 public:
63 
64  Event();
65  Event(const Event& event);
66 
76  Event(ScopePtr scope, boost::shared_ptr<void> payload,
77  const std::string& type, const std::string& method = "");
78 
79  Event(Scope scope, boost::shared_ptr<void> payload,
80  const std::string& type, const std::string& method = "");
81 
82  virtual ~Event();
83 
84  std::string getClassName() const;
85  void printContents(std::ostream& stream) const;
86 
94  DEPRECATED(boost::uint64_t getSequenceNumber() const);
95 
104  EventId getId() const;
105 
113  void setId(const rsc::misc::UUID& senderId, const boost::uint32_t& sequenceNumber);
114 
125  DEPRECATED(EventId getEventId() const);
126 
134  DEPRECATED(void setEventId(const rsc::misc::UUID& senderId,
135  const boost::uint32_t& sequenceNumber));
136 
146 
147  ScopePtr getScopePtr() const;
148  Scope getScope() const;
149  void setScopePtr(ScopePtr scope);
150  void setScope(const Scope& scope);
151 
153 
154  std::string getType() const;
155  void setType(const std::string& type);
156 
157  VoidPtr getData();
158  void setData(VoidPtr d);
159 
175 
183  bool addCause(const EventId& id);
184 
193  bool removeCause(const EventId& id);
194 
203  bool isCause(const EventId& id) const;
204 
211  std::set<EventId> getCauses() const;
212 
214 
221  std::string getMethod() const;
222 
228  void setMethod(const std::string& method);
229 
234 
240  MetaData getMetaData() const;
241 
247  MetaData& mutableMetaData();
248 
254  void setMetaData(const MetaData& metaData);
255 
257 
258 private:
259 
260  class Impl;
261  boost::scoped_ptr<Impl> d;
262 
263 };
264 
265 typedef boost::shared_ptr<Event> EventPtr;
266 
270 typedef std::pair<std::string, boost::shared_ptr<void> > AnnotatedData;
271 
272 }
boost::shared_ptr< Scope > ScopePtr
Definition: Event.h:49
boost::shared_ptr< void > VoidPtr
Definition: Event.h:52
std::pair< std::string, boost::shared_ptr< void > > AnnotatedData
A combination of data type and the actual data.
Definition: Event.h:270
Basic message that is exchanged between informers and listeners.
Definition: Event.h:61
boost::shared_ptr< EventId > EventIdPtr
Definition: Event.h:46
boost::scoped_ptr< Impl > d
Definition: Event.h:260
Framework-supplied meta data attached to each event that give information e.g.
Definition: MetaData.h:55
A unique ID for events in RSB.
Definition: EventId.h:48
boost::shared_ptr< Event > EventPtr
Definition: Event.h:265
Scope is a descriptor for a hierarchical channel of the unified bus.
Definition: Scope.h:46