31 #include <rsc/misc/langutils.h>
32 #include <rsc/runtime/ContainerIO.h>
38 const boost::posix_time::ptime MetaData::UNIX_EPOCH = boost::posix_time::ptime(
39 boost::gregorian::date(1970, boost::date_time::Jan, 1));
41 MetaData::MetaData() :
42 senderId(false), createTime(rsc::misc::currentTimeMicros()), sendTime(
43 0), receiveTime(0), deliverTime(0) {
56 <<
", deliverTime = " <<
deliverTime <<
", userTimes = "
73 const double& proposedValue) {
74 if (proposedValue < 0) {
75 throw invalid_argument(
"Timestamps must be >= 0");
77 if (proposedValue < 0.000001) {
78 timestamp = rsc::misc::currentTimeMicros();
80 timestamp = boost::uint64_t((proposedValue * 1000000) + 0.5);
85 const boost::uint64_t& proposedValue) {
86 if (proposedValue == 0) {
87 timestamp = rsc::misc::currentTimeMicros();
89 timestamp = proposedValue;
94 const boost::posix_time::ptime& proposedValue) {
95 boost::posix_time::time_duration delta = proposedValue -
UNIX_EPOCH;
97 if (delta.is_negative()) {
98 throw invalid_argument(
"Specified time is not a unix timestamp");
100 boost::uint64_t converted = delta.total_microseconds();
101 timestamp = converted;
166 for (map<string, boost::uint64_t>::const_iterator it =
userTimes.begin();
168 keys.insert(it->first);
178 map<string, boost::uint64_t>::const_iterator it =
userTimes.find(key);
180 throw invalid_argument(
"There is no user time with key '" + key +
"'.");
197 const boost::posix_time::ptime& time) {
212 for (map<string, string>::const_iterator it =
userInfos.begin();
214 keys.insert(it->first);
227 throw invalid_argument(
228 "No meta info registered under key '" + key +
"'");