Changes to attempt to silence bcc64x
[ACE_TAO.git] / ACE / ace / Time_Value_T.h
blob32b32df3d41fda56590cf1b6c25e6fadd78bc4ff
1 // -*- C++ -*-
3 //=============================================================================
4 /**
5 * @file Time_Value_T.h
7 * @author Martin Corino <mcorino@remedy.nl>
8 */
9 //=============================================================================
11 #ifndef ACE_TIME_VALUE_T_H
12 #define ACE_TIME_VALUE_T_H
14 #include /**/ "ace/pre.h"
16 #if !defined (ACE_LACKS_PRAGMA_ONCE)
17 # pragma once
18 #endif /* ACE_LACKS_PRAGMA_ONCE */
20 #include "ace/Time_Value.h"
22 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
24 /**
25 * @class ACE_Time_Value
27 * @brief Operations on "timeval" structures, which express time in
28 * seconds (secs) and microseconds (usecs).
30 * This class centralizes all the time related processing in
31 * ACE. These time values are typically used in conjunction with OS
32 * mechanisms like <select>, <poll>, or <cond_timedwait>.
34 template <class TIME_POLICY>
35 class ACE_Time_Value_T : public ACE_Time_Value
37 public:
38 typedef TIME_POLICY time_policy_t;
40 /// Default Constructor.
41 ACE_Time_Value_T () {}
43 /// Constructor.
44 explicit ACE_Time_Value_T (time_t sec, suseconds_t usec = 0)
45 : ACE_Time_Value (sec, usec) {}
47 // = Methods for converting to/from various time formats.
49 /// Construct the ACE_Time_Value from a timeval.
50 explicit ACE_Time_Value_T (const struct timeval &t)
51 : ACE_Time_Value (t) {}
53 /// Construct the ACE_Time_Value object from a timespec_t.
54 explicit ACE_Time_Value_T (const timespec_t &t)
55 : ACE_Time_Value (t) {}
57 /// Construct from ACE_Time_Value_T<TIME_POLICY>
58 ACE_Time_Value_T(const ACE_Time_Value_T<TIME_POLICY>& tv)
59 : ACE_Time_Value (tv),
60 time_policy_ (tv.time_policy_)
63 /// Construct from ACE_Time_Value
64 explicit ACE_Time_Value_T(const ACE_Time_Value& tv,
65 const TIME_POLICY& tp = TIME_POLICY ())
66 : ACE_Time_Value (tv),
67 time_policy_ (tp)
70 /// Destructor
71 virtual ~ACE_Time_Value_T () {}
73 /// Add @a tv to this.
74 ACE_Time_Value_T<TIME_POLICY> &operator += (const ACE_Time_Value &tv);
76 /// Add @a tv to this.
77 ACE_Time_Value_T<TIME_POLICY> &operator += (time_t tv);
79 /// Assign @ tv to this
80 ACE_Time_Value_T<TIME_POLICY> &operator = (const ACE_Time_Value_T<TIME_POLICY> &tv);
82 /// Assign @ tv to this
83 ACE_Time_Value_T<TIME_POLICY> &operator = (const ACE_Time_Value &tv);
85 /// Assign @ tv to this
86 ACE_Time_Value_T<TIME_POLICY> &operator = (time_t tv);
88 /// Subtract @a tv to this.
89 ACE_Time_Value_T<TIME_POLICY> &operator -= (const ACE_Time_Value &tv);
91 /// Subtract @a tv to this.
92 ACE_Time_Value_T<TIME_POLICY> &operator -= (time_t tv);
94 /**
95 \brief Multiply the time value by the @a d factor.
96 \note The result of the operator is valid for results from range
97 < (ACE_INT32_MIN, -999999), (ACE_INT32_MAX, 999999) >. Result
98 outside this range are saturated to a limit.
100 ACE_Time_Value_T<TIME_POLICY> &operator *= (double d);
102 /// Increment microseconds as postfix.
104 * @note The only reason this is here is to allow the use of ACE_Atomic_Op
105 * with ACE_Time_Value.
107 ACE_Time_Value_T<TIME_POLICY> operator++ (int);
109 /// Increment microseconds as prefix.
111 * @note The only reason this is here is to allow the use of ACE_Atomic_Op
112 * with ACE_Time_Value.
114 ACE_Time_Value_T<TIME_POLICY> &operator++ ();
116 /// Decrement microseconds as postfix.
118 * @note The only reason this is here is to allow the use of ACE_Atomic_Op
119 * with ACE_Time_Value.
121 ACE_Time_Value_T<TIME_POLICY> operator-- (int);
123 /// Decrement microseconds as prefix.
125 * @note The only reason this is here is to allow the use of ACE_Atomic_Op
126 * with ACE_Time_Value.
128 ACE_Time_Value_T<TIME_POLICY> &operator-- ();
130 /// Get current time of day according to time policy.
132 * @return Time value representing current time of day according to time policy.
134 virtual ACE_Time_Value now () const;
136 /// Converts absolute time value to time value relative to current time of day.
138 * @return Relative time value.
140 * @note This method uses it's time_policy_ member to get the current
141 * time of day.
142 * The developer is responsible for making sure this is an absolute
143 * time value compatible with the active time policy.
144 * Note that the returned time value has no notion of the time policy
145 * on which it is based anymore.
147 virtual ACE_Time_Value to_relative_time () const;
149 /// Converts relative time value to absolute time value based on current time of day.
151 * @return Absolute time value.
153 * @note This method uses it's time_policy_ member to get the current
154 * time of day.
155 * The developer is responsible for making sure this is a relative
156 * time value.
157 * Note that the returned time value has no notion of the time policy
158 * on which it is based anymore.
160 virtual ACE_Time_Value to_absolute_time () const;
162 /// Duplicates this time value (incl. time policy).
164 * @return Dynamically allocated time value copy.
166 * @note The caller is responsible for freeing the copy when it's not needed
167 * anymore.
169 virtual ACE_Time_Value * duplicate () const;
171 private:
172 TIME_POLICY time_policy_;
175 ACE_END_VERSIONED_NAMESPACE_DECL
177 #if defined (__ACE_INLINE__)
178 #include "ace/Time_Value_T.inl"
179 #endif /* __ACE_INLINE__ */
181 #include "ace/Time_Value_T.cpp"
183 #include /**/ "ace/post.h"
184 #endif /* ACE_TIME_VALUE_T_H */