RSB  0.19.0
MetaData.h
Go to the documentation of this file.
1 /* ============================================================
2  *
3  * This file is a part of the RSB project.
4  *
5  * Copyright (C) 2011 by Johannes Wienke <jwienke 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 
33 #include <boost/cstdint.hpp>
34 #include <boost/operators.hpp>
35 #include <boost/date_time.hpp>
36 
37 #include <rsc/runtime/Printable.h>
38 #include <rsc/misc/langutils.h>
39 #include <rsc/misc/UUID.h>
40 
41 #include "rsb/rsbexports.h"
42 
43 namespace rsb {
44 
55 class RSB_EXPORT MetaData: public virtual rsc::runtime::Printable,
56  boost::equality_comparable<MetaData> {
57 public:
58 
59  MetaData();
60  virtual ~MetaData();
61 
62  std::string getClassName() const;
63  void printContents(std::ostream& stream) const;
64 
71  DEPRECATED(rsc::misc::UUID getSenderId() const);
72 
79  DEPRECATED(void setSenderId(const rsc::misc::UUID& senderId));
80 
99  boost::uint64_t getCreateTime() const;
109  void setCreateTime(const boost::uint64_t& time = 0);
113  void setCreateTime(const double& time);
114  void setCreateTime(const boost::posix_time::ptime& time);
115 
122  boost::uint64_t getSendTime() const;
129  void setSendTime(const boost::uint64_t& time = 0);
130  void setSendTime(const double& time);
131  void setSendTime(const boost::posix_time::ptime& time);
132 
139  boost::uint64_t getReceiveTime() const;
146  void setReceiveTime(const boost::uint64_t& time = 0);
147  void setReceiveTime(const double& time);
148  void setReceiveTime(const boost::posix_time::ptime& time);
149 
157  boost::uint64_t getDeliverTime() const;
165  void setDeliverTime(const boost::uint64_t& time = 0);
166  void setDeliverTime(const double& time);
167  void setDeliverTime(const boost::posix_time::ptime& time);
169 
182  std::set<std::string> userTimeKeys() const;
189  bool hasUserTime(const std::string& key) const;
197  boost::uint64_t getUserTime(const std::string& key) const;
204  void setUserTime(const std::string& key, const boost::uint64_t& time = 0);
205  void setUserTime(const std::string& key, const double& time);
206  void setUserTime(const std::string& key, const boost::posix_time::ptime& time);
207 
208  std::map<std::string, boost::uint64_t>::const_iterator userTimesBegin() const;
209  std::map<std::string, boost::uint64_t>::const_iterator userTimesEnd() const;
211 
224  std::set<std::string> userInfoKeys() const;
231  bool hasUserInfo(const std::string& key) const;
239  std::string getUserInfo(const std::string& key) const;
247  void setUserInfo(const std::string& key, const std::string& value);
248  std::map<std::string, std::string>::const_iterator userInfosBegin() const;
249  std::map<std::string, std::string>::const_iterator userInfosEnd() const;
251 
252  bool operator==(const MetaData& other) const;
253 
254 private:
255  rsc::misc::UUID senderId;
256 
257  void checkedTimeStampSet(boost::uint64_t& timestamp, const boost::uint64_t& proposedValue);
258  void checkedTimeStampSet(boost::uint64_t& timestamp, const double& proposedValue);
259  void checkedTimeStampSet(boost::uint64_t& timestamp, const boost::posix_time::ptime& proposedValue);
260 
261  static const boost::posix_time::ptime UNIX_EPOCH;
262 
263  boost::uint64_t createTime;
264  boost::uint64_t sendTime;
265  boost::uint64_t receiveTime;
266  boost::uint64_t deliverTime;
267 
268  std::map<std::string, boost::uint64_t> userTimes;
269  std::map<std::string, std::string> userInfos;
270 
271 };
272 
273 RSB_EXPORT std::ostream& operator<<(std::ostream& stream, const MetaData& meta);
274 
275 }
static const boost::posix_time::ptime UNIX_EPOCH
Definition: MetaData.h:261
boost::uint64_t createTime
Definition: MetaData.h:263
boost::uint64_t deliverTime
Definition: MetaData.h:266
Framework-supplied meta data attached to each event that give information e.g.
Definition: MetaData.h:55
std::map< std::string, boost::uint64_t > userTimes
Definition: MetaData.h:268
ostream & operator<<(ostream &stream, const MetaData &meta)
Definition: MetaData.cpp:253
boost::uint64_t sendTime
Definition: MetaData.h:264
std::map< std::string, std::string > userInfos
Definition: MetaData.h:269
boost::uint64_t receiveTime
Definition: MetaData.h:265
rsc::misc::UUID senderId
Definition: MetaData.h:255