+ /** Update stored time to current time (seconds and nanoseconds) */
+ void stamp();
+
+ /** Set the time from a double value */
+ void setTime(const double& seconds)
+ {
+ sec_type wholeSecs = sec_type(floor(seconds));
+ nsec_type reminder;
+ reminder = nsec_type(floor((seconds - wholeSecs)*(1000*1000*1000)));
+ setTime(wholeSecs, reminder);
+ }
+ /** Set the time from a seconds/nanoseconds pair */
+ void setTime(sec_type sec, nsec_type nsec)
+ {
+ if (0 <= nsec) {
+ _sec = sec + nsec / (1000*1000*1000);
+ _nsec = nsec % (1000*1000*1000);
+ } else {
+ _sec = sec - 1 + nsec / (1000*1000*1000);
+ _nsec = (1000*1000*1000) + nsec % (1000*1000*1000);
+ }
+ }
+
+
+ /** @return the saved seconds of this time stamp */
+ long get_seconds() const { return _sec; }
+
+ /** @return the saved microseconds of this time stamp */
+ int get_usec() const { return _nsec/1000; }
+
+ /** @return the saved seconds of this time stamp */
+ const sec_type& getSeconds() const
+ { return _sec; }
+ /** @return the saved nanoseconds of this time stamp */
+ const nsec_type& getNanoSeconds() const
+ { return _nsec; }
+
+ /** @return the value of the timestamp in nanoseconds,
+ * use doubles to avoid overflow.
+ * If you need real nanosecond accuracy for time differences, build up a
+ * SGTimeStamp reference time and compare SGTimeStamps directly.
+ */
+ double toNSecs() const
+ { return _nsec + double(_sec)*1000*1000*1000; }
+
+ /** @return the value of the timestamp in microseconds,
+ * use doubles to avoid overflow.
+ * If you need real nanosecond accuracy for time differences, build up a
+ * SGTimeStamp reference time and compare SGTimeStamps directly.
+ */
+ double toUSecs() const
+ { return 1e-3*_nsec + double(_sec)*1000*1000; }
+
+ /** @return the value of the timestamp in milliseconds,
+ * use doubles to avoid overflow.
+ * If you need real nanosecond accuracy for time differences, build up a
+ * SGTimeStamp reference time and compare SGTimeStamps directly.
+ */
+ double toMSecs() const
+ { return 1e-6*_nsec + double(_sec)*1000; }
+
+ /** @return the value of the timestamp in seconds,
+ * use doubles to avoid overflow.
+ * If you need real nanosecond accuracy for time differences, build up a
+ * SGTimeStamp reference time and compare SGTimeStamps directly.
+ */
+ double toSecs() const
+ { return 1e-9*_nsec + _sec; }
+
+ /** Inplace addition.
+ */
+ SGTimeStamp& operator+=(const SGTimeStamp& c)
+ {
+ _sec += c._sec;
+ _nsec += c._nsec;
+ if ((1000*1000*1000) <= _nsec) {
+ _nsec -= (1000*1000*1000);
+ _sec += 1;
+ }
+ return *this;
+ }