summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorJosh Blum2013-06-21 00:08:01 -0700
committerJosh Blum2013-06-21 00:08:01 -0700
commitd08b195de44d2e85467de1764884c14973f92115 (patch)
treeb469890c0796d99fd979be5782563865714eba97 /include
parent37bd56f3301795e89294c048883324b0353237ef (diff)
downloadsandhi-d08b195de44d2e85467de1764884c14973f92115.tar.gz
sandhi-d08b195de44d2e85467de1764884c14973f92115.tar.bz2
sandhi-d08b195de44d2e85467de1764884c14973f92115.zip
gras: first cut at time tag class
Diffstat (limited to 'include')
-rw-r--r--include/gras/CMakeLists.txt1
-rw-r--r--include/gras/time_tag.hpp58
2 files changed, 59 insertions, 0 deletions
diff --git a/include/gras/CMakeLists.txt b/include/gras/CMakeLists.txt
index d0e3cfa..becd6cb 100644
--- a/include/gras/CMakeLists.txt
+++ b/include/gras/CMakeLists.txt
@@ -16,6 +16,7 @@ install(FILES
sbuffer.hpp
sbuffer.i
tags.hpp
+ time_tag.hpp
tags.i
tag_iter.hpp
tag_iter.i
diff --git a/include/gras/time_tag.hpp b/include/gras/time_tag.hpp
new file mode 100644
index 0000000..d350fa2
--- /dev/null
+++ b/include/gras/time_tag.hpp
@@ -0,0 +1,58 @@
+// Copyright (C) by Josh Blum. See LICENSE.txt for licensing information.
+
+#ifndef INCLUDED_GRAS_TIME_TAG_HPP
+#define INCLUDED_GRAS_TIME_TAG_HPP
+
+#include <gras/gras.hpp>
+#include <gras/chrono.hpp>
+#include <PMC/PMC.hpp>
+#include <boost/operators.hpp>
+
+namespace gras
+{
+
+struct GRAS_API TimeTag :
+ boost::less_than_comparable<TimeTag>,
+ boost::additive<TimeTag>
+{
+ //! Default contructor - hold time 0
+ TimeTag(void);
+
+ //! Create a time tag from ticks w/ default ticks per second
+ static TimeTag from_ticks(const time_ticks_t ticks);
+
+ //! Create a time tag from ticks w/ specified ticks per second
+ static TimeTag from_ticks(const time_ticks_t ticks, const double rate);
+
+ //! Create a time tag from a PMC containing a PMCTuple<2>(uint64, double)
+ static TimeTag from_pmc(const PMCC &p);
+
+ //! Convert this time tag to ticks w/ default ticks per second
+ time_ticks_t to_ticks(void);
+
+ //! Convert this time tag to ticks w/ specified ticks per second
+ time_ticks_t to_ticks(const double rate);
+
+ //! Convert this time tag to a PMC containing a PMCTuple<2>(uint64, double)
+ PMCC to_pmc(void);
+
+ //! Addition for additive interface
+ TimeTag &operator+=(const TimeTag &);
+
+ //! Subtraction for additive interface
+ TimeTag &operator-=(const TimeTag &);
+
+ //! full seconds
+ time_ticks_t _fsecs;
+
+ //! fractional ticks
+ time_ticks_t _ticks;
+};
+
+GRAS_API bool operator<(const TimeTag &lhs, const TimeTag &rhs);
+
+GRAS_API bool operator==(const TimeTag &lhs, const TimeTag &rhs);
+
+} //namespace gras
+
+#endif /*INCLUDED_GRAS_TIME_TAG_HPP*/