Changes to attempt to silence bcc64x
[ACE_TAO.git] / ACE / ace / Time_Policy.h
blob41a42eb1c39e09ee36ff11f795a2e03068e46818
1 #ifndef ACE_TIME_POLICY_H
2 #define ACE_TIME_POLICY_H
3 // -*- C++ -*-
4 /**
5 * @file Time_Policy.h
7 * @author Carlos O'Ryan <coryan@atdesk.com>
8 * @author Martin Corino <mcorino@remedy.nl>
9 */
10 #include /**/ "ace/pre.h"
12 #include /**/ "ace/config-all.h"
14 #include /**/ "ace/Time_Value_T.h"
16 #if !defined (ACE_LACKS_PRAGMA_ONCE)
17 # pragma once
18 #endif /* ACE_LACKS_PRAGMA_ONCE */
20 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
22 /**
23 * @class ACE_System_Time_Policy
25 * @brief Implement the system time policy for ACE.
27 * The most common time policy is to simply use
28 * ACE_OS::gettimeofday(), this class implements that policy, i.e., it
29 * simply calls that function.
31 class ACE_Export ACE_System_Time_Policy
33 public:
34 /// Return the current time according to this policy
35 ACE_Time_Value_T<ACE_System_Time_Policy> operator() () const;
37 /// Noop. Just here to satisfy backwards compatibility demands.
38 void set_gettimeofday (ACE_Time_Value (*gettimeofday)());
41 /**
42 * @class ACE_HR_Time_Policy
44 * @brief Implement a time policy based on the ACE Highres timer.
46 class ACE_Export ACE_HR_Time_Policy
48 public:
49 /// Return the current time according to this policy
50 ACE_Time_Value_T<ACE_HR_Time_Policy> operator() () const;
52 /// Noop. Just here to satisfy backwards compatibility demands.
53 void set_gettimeofday (ACE_Time_Value (*gettimeofday)());
56 /**
57 * @class ACE_FPointer_Timer_Policy
59 * @brief Implement a time policy based on a function pointer.
61 * This time policy allows dynamic changes to the source of time by
62 * using a function pointer.
64 class ACE_Export ACE_FPointer_Time_Policy
66 public:
67 /**
68 * @brief Default constructor uses ACE_OS::gettimeofday()
70 * ACE_T requires a default constructor that leaves the
71 * policy in a functional state. Therefore, a null pointer would
72 * not be desirable, in other words, we need a non-trivial default
73 * constructor.
75 ACE_FPointer_Time_Policy();
77 /**
78 * @typedef FPtr
80 * Short-hand for the right type of pointer to function.
82 typedef ACE_Time_Value (*FPtr)();
84 /**
85 * @brief Constructor from a pointer to function.
87 * Construct from a pointer to function.
89 ACE_FPointer_Time_Policy(FPtr f);
91 /// Return the current time according to this policy
92 ACE_Time_Value_T<ACE_FPointer_Time_Policy> operator()() const;
94 /// Satisfy backwards compatibility demands.
95 void set_gettimeofday (ACE_Time_Value (*gettimeofday)());
96 private:
97 FPtr function_;
100 class ACE_Dynamic_Time_Policy_Base; // forward decl
103 * @class ACE_Delegating_Time_Policy
105 * @brief Implement a time policy that delegates to a dynamic
106 * time policy.
108 class ACE_Export ACE_Delegating_Time_Policy
110 public:
111 ACE_Delegating_Time_Policy (ACE_Dynamic_Time_Policy_Base const * delegate = nullptr);
113 /// Return the current time according to this policy
114 ACE_Time_Value_T<ACE_Delegating_Time_Policy> operator()() const;
116 /// Set delegate
117 void set_delegate (ACE_Dynamic_Time_Policy_Base const * delegate);
119 ACE_Delegating_Time_Policy (const ACE_Delegating_Time_Policy&) = default;
120 ACE_Delegating_Time_Policy (ACE_Delegating_Time_Policy&&) = default;
121 ACE_Delegating_Time_Policy& operator = (ACE_Delegating_Time_Policy const &) = default;
122 ACE_Delegating_Time_Policy &operator = (ACE_Delegating_Time_Policy&&) = default;
124 /// Noop. Just here to satisfy backwards compatibility demands.
125 void set_gettimeofday (ACE_Time_Value (*gettimeofday)());
126 private:
127 ACE_Dynamic_Time_Policy_Base const * delegate_;
131 * @class ACE_Dynamic_Time_Policy_base
133 * @brief Abstract base class for dynamically loaded and/or shared
134 * time policies.
136 class ACE_Export ACE_Dynamic_Time_Policy_Base
138 public:
139 virtual ~ACE_Dynamic_Time_Policy_Base ();
141 /// Return the current time according to this policy
142 ACE_Time_Value_T<ACE_Delegating_Time_Policy> operator()() const;
144 /// Noop. Just here to satisfy backwards compatibility demands.
145 void set_gettimeofday (ACE_Time_Value (*gettimeofday)());
146 protected:
147 /// Return the current time according to policy implementation.
148 virtual ACE_Time_Value_T<ACE_Delegating_Time_Policy> gettimeofday () const = 0;
151 /// Temporarily, for backwards compatibility reasons, this will
152 /// be the default time policy. In time to be replaced by
153 /// ACE_System_Time_Policy.
154 typedef ACE_FPointer_Time_Policy ACE_Default_Time_Policy;
156 #if defined ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION_EXPORT
157 template class ACE_Export ACE_Time_Value_T<ACE_System_Time_Policy>;
158 template class ACE_Export ACE_Time_Value_T<ACE_HR_Time_Policy>;
159 template class ACE_Export ACE_Time_Value_T<ACE_FPointer_Time_Policy>;
160 template class ACE_Export ACE_Time_Value_T<ACE_Delegating_Time_Policy>;
161 #endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION_EXPORT */
163 ACE_END_VERSIONED_NAMESPACE_DECL
165 #if defined (__ACE_INLINE__)
166 #include "ace/Time_Policy.inl"
167 #endif /* __ACE_INLINE__ */
169 #include /**/ "ace/post.h"
170 #endif /* ACE_TIME_POLICY_H */