summaryrefslogtreecommitdiff
path: root/cpp/include/IceUtil/Time.h
diff options
context:
space:
mode:
authorMarc Laukien <marc@zeroc.com>2004-11-03 13:35:36 +0000
committerMarc Laukien <marc@zeroc.com>2004-11-03 13:35:36 +0000
commitffe3e8cee236c66d8092a17fd933b3d18a265f9c (patch)
tree668335c3a068671edb64eb7d2348eb9c7b214f84 /cpp/include/IceUtil/Time.h
parentmake depend. (diff)
downloadice-ffe3e8cee236c66d8092a17fd933b3d18a265f9c.tar.bz2
ice-ffe3e8cee236c66d8092a17fd933b3d18a265f9c.tar.xz
ice-ffe3e8cee236c66d8092a17fd933b3d18a265f9c.zip
time changes
Diffstat (limited to 'cpp/include/IceUtil/Time.h')
-rw-r--r--cpp/include/IceUtil/Time.h74
1 files changed, 46 insertions, 28 deletions
diff --git a/cpp/include/IceUtil/Time.h b/cpp/include/IceUtil/Time.h
index e69c99c5404..bff307bd12c 100644
--- a/cpp/include/IceUtil/Time.h
+++ b/cpp/include/IceUtil/Time.h
@@ -36,6 +36,10 @@ public:
Int64 toMilliSeconds() const;
Int64 toMicroSeconds() const;
+ double toSecondsDouble() const;
+ double toMilliSecondsDouble() const;
+ double toMicroSecondsDouble() const;
+
std::string toString() const;
Time operator-() const // Inlined for performance reasons.
@@ -95,20 +99,58 @@ public:
return _usec != rhs._usec;
}
- template<typename T>
- Time& operator*=(T rhs)
+ template<typename T> Time& operator*=(T rhs)
{
_usec *= rhs;
return *this;
}
- template<typename T>
- Time& operator/=(T rhs)
+ Time& operator*=(const Time& rhs)
+ {
+ _usec *= rhs._usec;
+ return *this;
+ }
+
+ template<typename T> Time operator*(T rhs) const
+ {
+ Time t;
+ t._usec = _usec * rhs;
+ return t;
+ }
+
+ Time operator*(const Time& rhs) const
+ {
+ Time t;
+ t._usec = _usec * rhs._usec;
+ return t;
+ }
+
+ template<typename T> Time& operator/=(T rhs)
{
_usec /= rhs;
return *this;
}
+ Time& operator/=(const Time& rhs)
+ {
+ _usec /= rhs._usec;
+ return *this;
+ }
+
+ template<typename T> Time operator/(T rhs) const
+ {
+ Time t;
+ t._usec = _usec / rhs;
+ return t;
+ }
+
+ Time operator/(const Time& rhs) const
+ {
+ Time t;
+ t._usec = _usec / rhs._usec;
+ return t;
+ }
+
private:
Time(Int64);
@@ -116,30 +158,6 @@ private:
Int64 _usec;
};
-template<typename T>
-Time operator*(const Time& lhs, T rhs)
-{
- return Time::microSeconds(static_cast<Int64>(lhs.toMicroSeconds() * rhs));
-}
-
-template<typename T>
-Time operator*(T rhs, const Time& lhs)
-{
- return Time::microSeconds(static_cast<Int64>(lhs * rhs.toMicroSeconds()));
-}
-
-template<typename T>
-Time operator/(const Time& lhs, T rhs)
-{
- return Time::microSeconds(static_cast<Int64>(lhs.toMicroSeconds() / rhs));
-}
-
-template<typename T>
-T operator/(T lhs, const Time& rhs)
-{
- return lhs * 1000000 / static_cast<T>(rhs.toMicroSeconds());
-}
-
ICE_UTIL_API std::ostream& operator<<(std::ostream&, const Time&);
} // End namespace IceUtil