1 #ifndef ACE_TIMER_QUEUE_ITERATOR_H
2 #define ACE_TIMER_QUEUE_ITERATOR_H
4 #include /**/ "ace/pre.h"
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
17 * @class ACE_Timer_Node_Dispatch_Info_T
19 * @brief Maintains generated dispatch information for Timer nodes.
22 class ACE_Timer_Node_Dispatch_Info_T
25 /// The type of object held in the queue
28 /// Asynchronous completion token associated with the timer.
31 /// Flag to check if the timer is recurring.
36 * @class ACE_Timer_Node_T
38 * @brief Maintains the state associated with a Timer entry.
41 class ACE_Timer_Node_T
44 /// Default constructor
45 ACE_Timer_Node_T (void);
48 ~ACE_Timer_Node_T (void);
51 typedef ACE_Timer_Node_Dispatch_Info_T
<TYPE
> DISPATCH_INFO
;
53 /// Singly linked list
54 void set (const TYPE
&type
,
56 const ACE_Time_Value
&t
,
57 const ACE_Time_Value
&i
,
58 ACE_Timer_Node_T
<TYPE
> *n
,
61 /// Doubly linked list version
62 void set (const TYPE
&type
,
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
,
73 TYPE
&get_type (void);
76 void set_type (TYPE
&type
);
78 /// Get the asynchronous completion token.
79 const void *get_act (void);
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 (void) 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 (void) 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 (void);
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 (void);
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 (void) 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 (void) const;
124 /// Declare the dynamic allocation hooks.
125 ACE_ALLOC_HOOK_DECLARE
;
128 /// Type of object stored in the Queue
131 /// Asynchronous completion token associated with the timer.
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
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).
152 * @class ACE_Timer_Queue_Iterator_T
154 * @brief Generic interface for iterating over a subclass of
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
166 ACE_Timer_Queue_Iterator_T (void);
169 virtual ~ACE_Timer_Queue_Iterator_T (void);
171 /// Positions the iterator at the earliest node in the Timer Queue
172 virtual void first (void) = 0;
174 /// Positions the iterator at the next node in the Timer Queue
175 virtual void next (void) = 0;
177 /// Returns true when there are no more nodes in the sequence
178 virtual bool isdone (void) const = 0;
180 /// Returns the node at the current position in the sequence
181 virtual ACE_Timer_Node_T
<TYPE
> *item (void) = 0;
184 ACE_END_VERSIONED_NAMESPACE_DECL
186 #if defined (__ACE_INLINE__)
187 #include "ace/Timer_Queue_Iterator.inl"
188 #endif /* __ACE_INLINE__ */
190 #if defined (ACE_TEMPLATES_REQUIRE_SOURCE)
191 #include "ace/Timer_Queue_Iterator.cpp"
192 #endif /* ACE_TEMPLATES_REQUIRE_SOURCE */
194 #if defined (ACE_TEMPLATES_REQUIRE_PRAGMA)
195 #pragma implementation ("Timer_Queue_Iterator.cpp")
196 #endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */
198 #include /**/ "ace/post.h"
199 #endif /* ACE_TIMER_QUEUE_ITERATOR_H */