RSB  0.10.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 
93  boost::uint64_t getSequenceNumber() const;
94 
106  DEPRECATED(rsc::misc::UUID getId() const);
115  EventId getEventId() const;
124  void setEventId(const rsc::misc::UUID& senderId, const boost::uint32_t& sequenceNumber);
125 
135 
136  ScopePtr getScopePtr() const;
137  Scope getScope() const;
138  void setScopePtr(ScopePtr scope);
139  void setScope(const Scope& scope);
140 
142 
143  std::string getType() const;
144  void setType(const std::string& type);
145 
146  VoidPtr getData();
147  void setData(VoidPtr d);
148 
164 
172  bool addCause(const EventId& id);
173 
182  bool removeCause(const EventId& id);
183 
192  bool isCause(const EventId& id) const;
193 
200  std::set<EventId> getCauses() const;
201 
203 
210  std::string getMethod() const;
211 
217  void setMethod(const std::string& method);
218 
223 
229  MetaData getMetaData() const;
230 
236  MetaData& mutableMetaData();
237 
243  void setMetaData(const MetaData& metaData);
244 
246 
247 private:
248 
249  class Impl;
250  boost::scoped_ptr<Impl> d;
251 
252 };
253 
254 typedef boost::shared_ptr<Event> EventPtr;
255 
259 typedef std::pair<std::string, boost::shared_ptr<void> > AnnotatedData;
260 
261 }