RSB  0.15.1
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 class MetaData;
48 class Scope;
49 typedef boost::shared_ptr<Scope> ScopePtr;
50 
51 typedef boost::shared_ptr<void> VoidPtr;
52 
60 class RSB_EXPORT Event: public virtual rsc::runtime::Printable {
61 public:
62 
63  Event();
64  Event(const Event& event);
65 
75  Event(ScopePtr scope, boost::shared_ptr<void> payload,
76  const std::string& type, const std::string& method = "");
77 
78  Event(Scope scope, boost::shared_ptr<void> payload,
79  const std::string& type, const std::string& method = "");
80 
81  virtual ~Event();
82 
83  std::string getClassName() const;
84  void printContents(std::ostream& stream) const;
85 
93  DEPRECATED(boost::uint64_t getSequenceNumber() const);
94 
103  EventId getId() const;
104 
112  void setId(const rsc::misc::UUID& senderId, const boost::uint32_t& sequenceNumber);
113 
124  DEPRECATED(EventId getEventId() const);
125 
133  DEPRECATED(void setEventId(const rsc::misc::UUID& senderId,
134  const boost::uint32_t& sequenceNumber));
135 
145 
146  ScopePtr getScopePtr() const;
147  Scope getScope() const;
148  void setScopePtr(ScopePtr scope);
149  void setScope(const Scope& scope);
150 
152 
153  std::string getType() const;
154  void setType(const std::string& type);
155 
156  VoidPtr getData();
157  void setData(VoidPtr d);
158 
174 
182  bool addCause(const EventId& id);
183 
192  bool removeCause(const EventId& id);
193 
202  bool isCause(const EventId& id) const;
203 
210  std::set<EventId> getCauses() const;
211 
213 
220  std::string getMethod() const;
221 
227  void setMethod(const std::string& method);
228 
233 
239  MetaData getMetaData() const;
240 
246  MetaData& mutableMetaData();
247 
253  void setMetaData(const MetaData& metaData);
254 
256 
257 private:
258 
259  class Impl;
260  boost::scoped_ptr<Impl> d;
261 
262 };
263 
264 typedef boost::shared_ptr<Event> EventPtr;
265 
269 typedef std::pair<std::string, boost::shared_ptr<void> > AnnotatedData;
270 
271 }
boost::shared_ptr< Scope > ScopePtr
Definition: Event.h:48
boost::shared_ptr< void > VoidPtr
Definition: Event.h:51
std::pair< std::string, boost::shared_ptr< void > > AnnotatedData
A combination of data type and the actual data.
Definition: Event.h:269
Basic message that is exchanged between informers and listeners.
Definition: Event.h:60
boost::scoped_ptr< Impl > d
Definition: Event.h:259
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:264
Scope is a descriptor for a hierarchical channel of the unified bus.
Definition: Scope.h:46