RSB  0.7.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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/UUID.h>
39 
40 #include "rsb/rsbexports.h"
41 
42 namespace rsb {
43 
54 class RSB_EXPORT MetaData: public virtual rsc::runtime::Printable,
55  boost::equality_comparable<MetaData> {
56 public:
57 
58  MetaData();
59  virtual ~MetaData();
60 
61  std::string getClassName() const;
62  void printContents(std::ostream& stream) const;
63 
69  rsc::misc::UUID getSenderId() const;
70 
76  void setSenderId(const rsc::misc::UUID& senderId);
77 
96  boost::uint64_t getCreateTime() const;
106  void setCreateTime(const boost::uint64_t& time = 0);
107  void setCreateTime(const double& time);
108  void setCreateTime(const boost::posix_time::ptime& time);
109 
116  boost::uint64_t getSendTime() const;
123  void setSendTime(const boost::uint64_t& time = 0);
124  void setSendTime(const double& time);
125  void setSendTime(const boost::posix_time::ptime& time);
126 
133  boost::uint64_t getReceiveTime() const;
140  void setReceiveTime(const boost::uint64_t& time = 0);
141  void setReceiveTime(const double& time);
142  void setReceiveTime(const boost::posix_time::ptime& time);
143 
151  boost::uint64_t getDeliverTime() const;
159  void setDeliverTime(const boost::uint64_t& time = 0);
160  void setDeliverTime(const double& time);
161  void setDeliverTime(const boost::posix_time::ptime& time);
163 
176  std::set<std::string> userTimeKeys() const;
183  bool hasUserTime(const std::string& key) const;
191  boost::uint64_t getUserTime(const std::string& key) const;
198  void setUserTime(const std::string& key, const boost::uint64_t& time = 0);
199  void setUserTime(const std::string& key, const double& time);
200  void setUserTime(const std::string& key, const boost::posix_time::ptime& time);
201 
202  std::map<std::string, boost::uint64_t>::const_iterator userTimesBegin() const;
203  std::map<std::string, boost::uint64_t>::const_iterator userTimesEnd() const;
205 
218  std::set<std::string> userInfoKeys() const;
225  bool hasUserInfo(const std::string& key) const;
233  std::string getUserInfo(const std::string& key) const;
241  void setUserInfo(const std::string& key, const std::string& value);
242  std::map<std::string, std::string>::const_iterator userInfosBegin() const;
243  std::map<std::string, std::string>::const_iterator userInfosEnd() const;
245 
246  bool operator==(const MetaData& other) const;
247 
248 private:
249  rsc::misc::UUID senderId;
250 
251  void checkedTimeStampSet(boost::uint64_t& timestamp, const boost::uint64_t& proposedValue);
252  void checkedTimeStampSet(boost::uint64_t& timestamp, const double& proposedValue);
253  void checkedTimeStampSet(boost::uint64_t& timestamp, const boost::posix_time::ptime& proposedValue);
254 
255  static const boost::posix_time::ptime UNIX_EPOCH;
256 
257  boost::uint64_t createTime;
258  boost::uint64_t sendTime;
259  boost::uint64_t receiveTime;
260  boost::uint64_t deliverTime;
261 
262  std::map<std::string, boost::uint64_t> userTimes;
263  std::map<std::string, std::string> userInfos;
264 
265 };
266 
267 RSB_EXPORT std::ostream& operator<<(std::ostream& stream, const MetaData& meta);
268 
269 }