#ifndef __JTIME1__ #define __JTIME1__ #include #include #include "JIO/JSerialisable.hh" #include "JLang/JManip.hh" /** * \author mdejong */ namespace JGEOMETRY3D {} namespace JPP { using namespace JGEOMETRY3D; } namespace JGEOMETRY3D { using JIO::JReader; using JIO::JWriter; /** * Time. */ class JTime { public: /** * Default constructor. */ JTime() : __t(0.0) {} /** * Constructor. * * \param t time */ JTime(const double t) : __t(t) {} /** * Prefix unary minus. * * \return time */ JTime& negate() { __t = -__t; return *this; } /** * Addition operator. * * \param value time * \return time */ JTime& add(const JTime& value) { __t += value.getT(); return *this; } /** * Subtraction operator. * * \param value time * \return time */ JTime& sub(const JTime& value) { __t -= value.getT(); return *this; } /** * Multiplication operator. * * \param value multiplication factor * \return time */ JTime& mul(const double value) { __t *= value; return *this; } /** * Division operator. * * \param value multiplication factor * \return time */ JTime& div(const double value) { __t /= value; return *this; } /** * Get time. * * \return time */ inline double getT() const { return __t; } /** * Read time from input. * * \param in input stream * \param time time * \return input stream */ friend inline std::istream& operator>>(std::istream& in, JTime& time) { in >> time.__t; return in; } /** * Write time to output. * * \param out output stream * \param time time * \return output stream */ friend inline std::ostream& operator<<(std::ostream& out, const JTime& time) { const JFormat format(out, getFormat(JFormat_t(9, 3, std::ios::fixed | std::ios::showpos))); out << time.__t; return out; } /** * Read time from input. * * \param in reader * \param time time * \return reader */ friend inline JReader& operator>>(JReader& in, JTime& time) { in >> time.__t; return in; } /** * Write time to output. * * \param out writer * \param time time * \return writer */ friend inline JWriter& operator<<(JWriter& out, const JTime& time) { out << time.__t; return out; } protected: double __t; }; } #endif