Changes to attempt to silence bcc64x
[ACE_TAO.git] / ACE / ace / Timer_Queue_Iterator.h
blobd550397791bc3b7839c576d8be1aee2123afe4c6
1 #ifndef ACE_TIMER_QUEUE_ITERATOR_H
2 #define ACE_TIMER_QUEUE_ITERATOR_H
4 #include /**/ "ace/pre.h"
6 /**
7 * @file Timer_Queue_Iterator.h
9 * Re-factored from Timer_Queue_T.h
12 #include "ace/Time_Value.h"
14 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
16 /**
17 * @class ACE_Timer_Node_Dispatch_Info_T
19 * @brief Maintains generated dispatch information for Timer nodes.
21 template <class TYPE>
22 class ACE_Timer_Node_Dispatch_Info_T
24 public:
25 /// The type of object held in the queue
26 TYPE type_;
28 /// Asynchronous completion token associated with the timer.
29 const void *act_;
31 /// Flag to check if the timer is recurring.
32 int recurring_timer_;
35 /**
36 * @class ACE_Timer_Node_T
38 * @brief Maintains the state associated with a Timer entry.
40 template <class TYPE>
41 class ACE_Timer_Node_T
43 public:
44 /// Default constructor
45 ACE_Timer_Node_T ();
47 /// Destructor
48 ~ACE_Timer_Node_T ();
50 /// Useful typedef ..
51 typedef ACE_Timer_Node_Dispatch_Info_T <TYPE> DISPATCH_INFO;
53 /// Singly linked list
54 void set (const TYPE &type,
55 const void *a,
56 const ACE_Time_Value &t,
57 const ACE_Time_Value &i,
58 ACE_Timer_Node_T<TYPE> *n,
59 long timer_id);
61 /// Doubly linked list version
62 void set (const TYPE &type,
63 const void *a,
64 const ACE_Time_Value &t,
65 const ACE_Time_Value &i,
66 ACE_Timer_Node_T<TYPE> *p,
67 ACE_Timer_Node_T<TYPE> *n,
68 long timer_id);
70 // = Accessors
72 /// Get the type.
73 TYPE &get_type ();
75 /// Set the type.
76 void set_type (TYPE &type);
78 /// Get the asynchronous completion token.
79 const void *get_act ();
81 /// Set the asynchronous completion token.
82 void set_act (void *act);
84 /// Get the timer value.
85 const ACE_Time_Value &get_timer_value () const;
87 /// Set the timer value.
88 void set_timer_value (const ACE_Time_Value &timer_value);
90 /// Get the timer interval.
91 const ACE_Time_Value &get_interval () const;
93 /// Set the timer interval.
94 void set_interval (const ACE_Time_Value &interval);
96 /// Get the previous pointer.
97 ACE_Timer_Node_T<TYPE> *get_prev ();
99 /// Set the previous pointer.
100 void set_prev (ACE_Timer_Node_T<TYPE> *prev);
102 /// Get the next pointer.
103 ACE_Timer_Node_T<TYPE> *get_next ();
105 /// Set the next pointer.
106 void set_next (ACE_Timer_Node_T<TYPE> *next);
108 /// Get the timer_id.
109 long get_timer_id () const;
111 /// Set the timer_id.
112 void set_timer_id (long timer_id);
114 /// Get the dispatch info. The dispatch information is got
115 /// through @a info. This form helps us in preventing allocation and
116 /// deleting data along the criticl path.
117 /// @todo We may want to have a copying version too, so that our
118 /// interface will be complete..
119 void get_dispatch_info (ACE_Timer_Node_Dispatch_Info_T <TYPE> &info);
121 /// Dump the state of an TYPE.
122 void dump () const;
124 /// Declare the dynamic allocation hooks.
125 ACE_ALLOC_HOOK_DECLARE;
127 private:
128 /// Type of object stored in the Queue
129 TYPE type_;
131 /// Asynchronous completion token associated with the timer.
132 const void *act_;
134 /// Time until the timer expires.
135 ACE_Time_Value timer_value_;
137 /// If this is a periodic timer this holds the time until the next
138 /// timeout.
139 ACE_Time_Value interval_;
141 /// Pointer to previous timer.
142 ACE_Timer_Node_T<TYPE> *prev_;
144 /// Pointer to next timer.
145 ACE_Timer_Node_T<TYPE> *next_;
147 /// Id of this timer (used to cancel timers before they expire).
148 long timer_id_;
152 * @class ACE_Timer_Queue_Iterator_T
154 * @brief Generic interface for iterating over a subclass of
155 * ACE_Timer_Queue.
157 * This is a generic iterator that can be used to visit every
158 * node of a timer queue. Be aware that it isn't guaranteed
159 * that the transversal will be in order of timeout values.
161 template <class TYPE>
162 class ACE_Timer_Queue_Iterator_T
164 public:
165 /// Constructor.
166 ACE_Timer_Queue_Iterator_T () = default;
168 /// Destructor.
169 virtual ~ACE_Timer_Queue_Iterator_T ();
171 /// Positions the iterator at the earliest node in the Timer Queue
172 virtual void first () = 0;
174 /// Positions the iterator at the next node in the Timer Queue
175 virtual void next () = 0;
177 /// Returns true when there are no more nodes in the sequence
178 virtual bool isdone () const = 0;
180 /// Returns the node at the current position in the sequence
181 virtual ACE_Timer_Node_T<TYPE> *item () = 0;
184 ACE_END_VERSIONED_NAMESPACE_DECL
186 #if defined (__ACE_INLINE__)
187 #include "ace/Timer_Queue_Iterator.inl"
188 #endif /* __ACE_INLINE__ */
190 #include "ace/Timer_Queue_Iterator.cpp"
192 #include /**/ "ace/post.h"
193 #endif /* ACE_TIMER_QUEUE_ITERATOR_H */