1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: timestamp.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef CONFIGMGR_TIMESTAMP_HXX
32 #define CONFIGMGR_TIMESTAMP_HXX
34 #include <vos/timer.hxx>
38 ////////////////////////////////////////////////////////////////////////////////
42 vos::TTimeValue m_aTime
;
44 TimeInterval() : m_aTime()
48 TimeInterval(sal_uInt32 nSeconds
) : m_aTime(nSeconds
,0)
52 TimeInterval(const TimeValue
& rTimeValue
) : m_aTime(rTimeValue
)
55 sal_Bool
isEmpty() const { return m_aTime
.isEmpty(); }
57 vos::TTimeValue
const& getTimeValue() const { return m_aTime
; }
59 ////////////////////////////////////////////////////////////////////////////////
63 vos::TTimeValue m_aTime
;
65 TimeStamp() : m_aTime()
69 TimeStamp(TimeValue
const& rTimeValue
) : m_aTime(rTimeValue
)
72 TimeStamp
& operator += (TimeInterval
const& aInterval
)
73 { m_aTime
.addTime(aInterval
.getTimeValue()); return *this; }
75 vos::TTimeValue
const& getTimeValue() const { return m_aTime
; }
77 sal_Bool
isNever() const;
79 static TimeStamp
getCurrentTime();
80 static TimeStamp
never(); // is later than (>) any other TimeStamp
84 TimeStamp
operator +(TimeStamp
const& aTime
, TimeInterval
const& aInterval
)
86 TimeStamp
aResult(aTime
);
91 TimeStamp
operator +(TimeInterval
const& aInterval
, TimeStamp
const& aTime
)
93 TimeStamp
aResult(aTime
);
97 ////////////////////////////////////////////////////////////////////////////////
98 inline sal_Bool
operator ==(TimeStamp
const& lhs
, TimeStamp
const& rhs
)
99 { return lhs
.getTimeValue() == rhs
.getTimeValue(); }
100 inline sal_Bool
operator < (TimeStamp
const& lhs
, TimeStamp
const& rhs
)
101 { return lhs
.getTimeValue() < rhs
.getTimeValue(); }
102 inline sal_Bool
operator > (TimeStamp
const& lhs
, TimeStamp
const& rhs
)
103 { return lhs
.getTimeValue() > rhs
.getTimeValue(); }
105 inline sal_Bool
operator !=(TimeStamp
const& lhs
, TimeStamp
const& rhs
)
106 { return !(lhs
== rhs
); }
107 inline sal_Bool
operator <=(TimeStamp
const& lhs
, TimeStamp
const& rhs
)
108 { return !(rhs
< lhs
); }
109 inline sal_Bool
operator >=(TimeStamp
const& lhs
, TimeStamp
const& rhs
)
110 { return !(lhs
< rhs
); }
112 inline sal_Bool
TimeStamp::isNever() const
114 return never() <= *this;
116 ////////////////////////////////////////////////////////////////////////////////
118 struct ltTimeStamp
//: std::binary_function<TimeStamp,TimeStamp,bool>
120 bool operator()(TimeStamp
const& lhs
, TimeStamp
const& rhs
) const
121 { return !!(lhs
< rhs
); }
124 ////////////////////////////////////////////////////////////////////////////////
125 } // namespace configmgr
127 #endif // CONFIGMGR_TIMESTAMP_HXX