RSB  0.7.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 
90  DEPRECATED(boost::uint64_t getSequenceNumber() const);
91 
103  DEPRECATED(rsc::misc::UUID getId() const);
112  EventId getEventId() const;
121  void setEventId(const rsc::misc::UUID& senderId, const boost::uint32_t& sequenceNumber);
122 
132 
133  ScopePtr getScopePtr() const;
134  Scope getScope() const;
135  void setScopePtr(ScopePtr scope);
136  void setScope(const Scope& scope);
137 
139 
140  std::string getType() const;
141  void setType(const std::string& type);
142 
143  VoidPtr getData();
144  void setData(VoidPtr d);
145 
161 
169  bool addCause(const EventId& id);
170 
179  bool removeCause(const EventId& id);
180 
189  bool isCause(const EventId& id) const;
190 
197  std::set<EventId> getCauses() const;
198 
200 
207  std::string getMethod() const;
208 
214  void setMethod(const std::string& method);
215 
220 
226  MetaData getMetaData() const;
227 
233  MetaData& mutableMetaData();
234 
240  void setMetaData(const MetaData& metaData);
241 
243 
244 private:
245 
246  class Impl;
247  boost::scoped_ptr<Impl> d;
248 
249 };
250 
251 typedef boost::shared_ptr<Event> EventPtr;
252 
256 typedef std::pair<std::string, boost::shared_ptr<void> > AnnotatedData;
257 
258 }