RSB  0.10.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);
110  void setCreateTime(const double& time);
111  void setCreateTime(const boost::posix_time::ptime& time);
112 
119  boost::uint64_t getSendTime() const;
126  void setSendTime(const boost::uint64_t& time = 0);
127  void setSendTime(const double& time);
128  void setSendTime(const boost::posix_time::ptime& time);
129 
136  boost::uint64_t getReceiveTime() const;
143  void setReceiveTime(const boost::uint64_t& time = 0);
144  void setReceiveTime(const double& time);
145  void setReceiveTime(const boost::posix_time::ptime& time);
146 
154  boost::uint64_t getDeliverTime() const;
162  void setDeliverTime(const boost::uint64_t& time = 0);
163  void setDeliverTime(const double& time);
164  void setDeliverTime(const boost::posix_time::ptime& time);
166 
179  std::set<std::string> userTimeKeys() const;
186  bool hasUserTime(const std::string& key) const;
194  boost::uint64_t getUserTime(const std::string& key) const;
201  void setUserTime(const std::string& key, const boost::uint64_t& time = 0);
202  void setUserTime(const std::string& key, const double& time);
203  void setUserTime(const std::string& key, const boost::posix_time::ptime& time);
204 
205  std::map<std::string, boost::uint64_t>::const_iterator userTimesBegin() const;
206  std::map<std::string, boost::uint64_t>::const_iterator userTimesEnd() const;
208 
221  std::set<std::string> userInfoKeys() const;
228  bool hasUserInfo(const std::string& key) const;
236  std::string getUserInfo(const std::string& key) const;
244  void setUserInfo(const std::string& key, const std::string& value);
245  std::map<std::string, std::string>::const_iterator userInfosBegin() const;
246  std::map<std::string, std::string>::const_iterator userInfosEnd() const;
248 
249  bool operator==(const MetaData& other) const;
250 
251 private:
252  rsc::misc::UUID senderId;
253 
254  void checkedTimeStampSet(boost::uint64_t& timestamp, const boost::uint64_t& proposedValue);
255  void checkedTimeStampSet(boost::uint64_t& timestamp, const double& proposedValue);
256  void checkedTimeStampSet(boost::uint64_t& timestamp, const boost::posix_time::ptime& proposedValue);
257 
258  static const boost::posix_time::ptime UNIX_EPOCH;
259 
260  boost::uint64_t createTime;
261  boost::uint64_t sendTime;
262  boost::uint64_t receiveTime;
263  boost::uint64_t deliverTime;
264 
265  std::map<std::string, boost::uint64_t> userTimes;
266  std::map<std::string, std::string> userInfos;
267 
268 };
269 
270 RSB_EXPORT std::ostream& operator<<(std::ostream& stream, const MetaData& meta);
271 
272 }