1 #ifndef ACE_STREAM_MODULES_CPP
2 #define ACE_STREAM_MODULES_CPP
4 #include "ace/Stream_Modules.h"
5 #include "ace/OS_NS_string.h"
7 #if !defined (ACE_LACKS_PRAGMA_ONCE)
9 #endif /* ACE_LACKS_PRAGMA_ONCE */
12 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
14 ACE_ALLOC_HOOK_DEFINE_Tyc(ACE_Stream_Head
)
16 template <ACE_SYNCH_DECL
, class TIME_POLICY
>
17 ACE_Stream_Head
<ACE_SYNCH_USE
, TIME_POLICY
>::ACE_Stream_Head ()
19 ACE_TRACE ("ACE_Stream_Head<ACE_SYNCH_USE, TIME_POLICY>::ACE_Stream_Head");
22 template <ACE_SYNCH_DECL
, class TIME_POLICY
>
23 ACE_Stream_Head
<ACE_SYNCH_USE
, TIME_POLICY
>::~ACE_Stream_Head ()
25 ACE_TRACE ("ACE_Stream_Head<ACE_SYNCH_USE, TIME_POLICY>::~ACE_Stream_Head");
28 template <ACE_SYNCH_DECL
, class TIME_POLICY
> void
29 ACE_Stream_Head
<ACE_SYNCH_USE
, TIME_POLICY
>::dump () const
31 #if defined (ACE_HAS_DUMP)
32 ACE_TRACE ("ACE_Stream_Head<ACE_SYNCH_USE, TIME_POLICY>::dump");
33 #endif /* ACE_HAS_DUMP */
36 // ACE_Module that act as the head and tail of a Stream.
38 template <ACE_SYNCH_DECL
, class TIME_POLICY
> int
39 ACE_Stream_Head
<ACE_SYNCH_USE
, TIME_POLICY
>::open (void *)
41 ACE_TRACE ("ACE_Stream_Head<ACE_SYNCH_USE, TIME_POLICY>::open");
45 template <ACE_SYNCH_DECL
, class TIME_POLICY
> int
46 ACE_Stream_Head
<ACE_SYNCH_USE
, TIME_POLICY
>::close (u_long
)
48 ACE_TRACE ("ACE_Stream_Head<ACE_SYNCH_USE, TIME_POLICY>::close");
52 template <ACE_SYNCH_DECL
, class TIME_POLICY
> int
53 ACE_Stream_Head
<ACE_SYNCH_USE
, TIME_POLICY
>::svc ()
55 ACE_TRACE ("ACE_Stream_Head<ACE_SYNCH_USE, TIME_POLICY>::svc");
59 template <ACE_SYNCH_DECL
, class TIME_POLICY
> int
60 ACE_Stream_Head
<ACE_SYNCH_USE
, TIME_POLICY
>::control (ACE_Message_Block
*mb
)
62 ACE_TRACE ("ACE_Stream_Head<ACE_SYNCH_USE, TIME_POLICY>::control");
63 ACE_IO_Cntl_Msg
*ioc
= (ACE_IO_Cntl_Msg
*) mb
->rd_ptr ();
64 ACE_IO_Cntl_Msg::ACE_IO_Cntl_Cmds cmd
;
66 switch (cmd
= ioc
->cmd ())
68 case ACE_IO_Cntl_Msg::SET_LWM
:
69 case ACE_IO_Cntl_Msg::SET_HWM
:
70 this->water_marks (cmd
, *(size_t *) mb
->cont ()->rd_ptr ());
79 // Performs canonical flushing at the ACE_Stream Head.
81 template <ACE_SYNCH_DECL
, class TIME_POLICY
> int
82 ACE_Stream_Head
<ACE_SYNCH_USE
, TIME_POLICY
>::canonical_flush (ACE_Message_Block
*mb
)
84 ACE_TRACE ("ACE_Stream_Head<ACE_SYNCH_USE, TIME_POLICY>::canonical_flush");
85 char *cp
= mb
->rd_ptr ();
87 if (ACE_BIT_ENABLED (*cp
, ACE_Task_Flags::ACE_FLUSHR
))
89 this->flush (ACE_Task_Flags::ACE_FLUSHALL
);
90 ACE_CLR_BITS (*cp
, ACE_Task_Flags::ACE_FLUSHR
);
93 if (ACE_BIT_ENABLED (*cp
, ACE_Task_Flags::ACE_FLUSHW
))
94 return this->reply (mb
);
100 template <ACE_SYNCH_DECL
, class TIME_POLICY
> int
101 ACE_Stream_Head
<ACE_SYNCH_USE
, TIME_POLICY
>::put (ACE_Message_Block
*mb
,
104 ACE_TRACE ("ACE_Stream_Head<ACE_SYNCH_USE, TIME_POLICY>::put");
107 if (mb
->msg_type () == ACE_Message_Block::MB_IOCTL
108 && (res
= this->control (mb
)) == -1)
111 if (this->is_writer ())
112 return this->put_next (mb
, tv
);
113 else // this->is_reader ()
115 switch (mb
->msg_type ())
117 case ACE_Message_Block::MB_FLUSH
:
118 return this->canonical_flush (mb
);
123 return this->putq (mb
, tv
);
127 template <ACE_SYNCH_DECL
, class TIME_POLICY
> int
128 ACE_Stream_Head
<ACE_SYNCH_USE
, TIME_POLICY
>::init (int, ACE_TCHAR
*[])
130 ACE_TRACE ("ACE_Stream_Head<ACE_SYNCH_USE, TIME_POLICY>::init");
134 template <ACE_SYNCH_DECL
, class TIME_POLICY
> int
135 ACE_Stream_Head
<ACE_SYNCH_USE
, TIME_POLICY
>::info (ACE_TCHAR
**strp
, size_t length
) const
137 ACE_TRACE ("ACE_Stream_Head<ACE_SYNCH_USE, TIME_POLICY>::info");
138 const ACE_TCHAR
*name
= this->name ();
140 if (*strp
== 0 && (*strp
= ACE_OS::strdup (name
)) == 0)
143 ACE_OS::strsncpy (*strp
, name
, length
);
144 return static_cast<int> (ACE_OS::strlen (name
));
147 template <ACE_SYNCH_DECL
, class TIME_POLICY
> int
148 ACE_Stream_Head
<ACE_SYNCH_USE
, TIME_POLICY
>::fini ()
150 ACE_TRACE ("ACE_Stream_Head<ACE_SYNCH_USE, TIME_POLICY>::fini");
154 ACE_ALLOC_HOOK_DEFINE_Tyc(ACE_Stream_Tail
)
156 template <ACE_SYNCH_DECL
, class TIME_POLICY
>
157 ACE_Stream_Tail
<ACE_SYNCH_USE
, TIME_POLICY
>::ACE_Stream_Tail ()
159 ACE_TRACE ("ACE_Stream_Tail<ACE_SYNCH_USE, TIME_POLICY>::ACE_Stream_Tail");
162 template <ACE_SYNCH_DECL
, class TIME_POLICY
>
163 ACE_Stream_Tail
<ACE_SYNCH_USE
, TIME_POLICY
>::~ACE_Stream_Tail ()
165 ACE_TRACE ("ACE_Stream_Tail<ACE_SYNCH_USE, TIME_POLICY>::~ACE_Stream_Tail");
168 template <ACE_SYNCH_DECL
, class TIME_POLICY
> void
169 ACE_Stream_Tail
<ACE_SYNCH_USE
, TIME_POLICY
>::dump () const
171 #if defined (ACE_HAS_DUMP)
172 ACE_TRACE ("ACE_Stream_Tail<ACE_SYNCH_USE, TIME_POLICY>::dump");
173 #endif /* ACE_HAS_DUMP */
176 template <ACE_SYNCH_DECL
, class TIME_POLICY
> int
177 ACE_Stream_Tail
<ACE_SYNCH_USE
, TIME_POLICY
>::open (void *)
179 ACE_TRACE ("ACE_Stream_Tail<ACE_SYNCH_USE, TIME_POLICY>::open");
183 template <ACE_SYNCH_DECL
, class TIME_POLICY
> int
184 ACE_Stream_Tail
<ACE_SYNCH_USE
, TIME_POLICY
>::close (u_long
)
186 ACE_TRACE ("ACE_Stream_Tail<ACE_SYNCH_USE, TIME_POLICY>::close");
190 template <ACE_SYNCH_DECL
, class TIME_POLICY
> int
191 ACE_Stream_Tail
<ACE_SYNCH_USE
, TIME_POLICY
>::svc ()
193 ACE_TRACE ("ACE_Stream_Tail<ACE_SYNCH_USE, TIME_POLICY>::svc");
197 template <ACE_SYNCH_DECL
, class TIME_POLICY
> int
198 ACE_Stream_Tail
<ACE_SYNCH_USE
, TIME_POLICY
>::control (ACE_Message_Block
*mb
)
200 ACE_TRACE ("ACE_Stream_Tail<ACE_SYNCH_USE, TIME_POLICY>::control");
201 ACE_IO_Cntl_Msg
*ioc
= (ACE_IO_Cntl_Msg
*) mb
->rd_ptr ();
202 ACE_IO_Cntl_Msg::ACE_IO_Cntl_Cmds cmd
;
204 switch (cmd
= ioc
->cmd ())
206 case ACE_IO_Cntl_Msg::SET_LWM
:
207 case ACE_IO_Cntl_Msg::SET_HWM
:
209 size_t wm_size
= *(size_t *) mb
->cont ()->rd_ptr ();
211 this->water_marks (cmd
, wm_size
);
212 this->sibling ()->water_marks (cmd
, wm_size
);
217 mb
->msg_type (ACE_Message_Block::MB_IOCNAK
);
220 return this->reply (mb
);
223 // Perform flush algorithm as though we were the driver.
225 template <ACE_SYNCH_DECL
, class TIME_POLICY
> int
226 ACE_Stream_Tail
<ACE_SYNCH_USE
, TIME_POLICY
>::canonical_flush (ACE_Message_Block
*mb
)
228 ACE_TRACE ("ACE_Stream_Tail<ACE_SYNCH_USE, TIME_POLICY>::canonical_flush");
229 char *cp
= mb
->rd_ptr ();
231 if (ACE_BIT_ENABLED (*cp
, ACE_Task_Flags::ACE_FLUSHW
))
233 this->flush (ACE_Task_Flags::ACE_FLUSHALL
);
234 ACE_CLR_BITS (*cp
, ACE_Task_Flags::ACE_FLUSHW
);
237 if (ACE_BIT_ENABLED (*cp
, ACE_Task_Flags::ACE_FLUSHR
))
239 this->sibling ()->flush (ACE_Task_Flags::ACE_FLUSHALL
);
240 return this->reply (mb
);
248 template <ACE_SYNCH_DECL
, class TIME_POLICY
> int
249 ACE_Stream_Tail
<ACE_SYNCH_USE
, TIME_POLICY
>::put (ACE_Message_Block
*mb
,
252 ACE_TRACE ("ACE_Stream_Tail<ACE_SYNCH_USE, TIME_POLICY>::put");
254 if (this->is_writer ())
256 switch (mb
->msg_type ())
258 case ACE_Message_Block::MB_IOCTL
:
259 return this->control (mb
);
271 template <ACE_SYNCH_DECL
, class TIME_POLICY
> int
272 ACE_Stream_Tail
<ACE_SYNCH_USE
, TIME_POLICY
>::init (int, ACE_TCHAR
*[])
274 ACE_TRACE ("ACE_Stream_Tail<ACE_SYNCH_USE, TIME_POLICY>::init");
278 template <ACE_SYNCH_DECL
, class TIME_POLICY
> int
279 ACE_Stream_Tail
<ACE_SYNCH_USE
, TIME_POLICY
>::info (ACE_TCHAR
**strp
, size_t length
) const
281 ACE_TRACE ("ACE_Stream_Tail<ACE_SYNCH_USE, TIME_POLICY>::info");
282 const ACE_TCHAR
*name
= this->name ();
284 if (*strp
== 0 && (*strp
= ACE_OS::strdup (name
)) == 0)
287 ACE_OS::strsncpy (*strp
, name
, length
);
288 return static_cast<int> (ACE_OS::strlen (name
));
291 template <ACE_SYNCH_DECL
, class TIME_POLICY
> int
292 ACE_Stream_Tail
<ACE_SYNCH_USE
, TIME_POLICY
>::fini ()
294 ACE_TRACE ("ACE_Stream_Tail<ACE_SYNCH_USE, TIME_POLICY>::fini");
298 ACE_ALLOC_HOOK_DEFINE_Tyc(ACE_Thru_Task
)
300 template <ACE_SYNCH_DECL
, class TIME_POLICY
>
301 ACE_Thru_Task
<ACE_SYNCH_USE
, TIME_POLICY
>::ACE_Thru_Task ()
303 ACE_TRACE ("ACE_Thru_Task<ACE_SYNCH_USE, TIME_POLICY>::ACE_Thru_Task");
306 template <ACE_SYNCH_DECL
, class TIME_POLICY
>
307 ACE_Thru_Task
<ACE_SYNCH_USE
, TIME_POLICY
>::~ACE_Thru_Task ()
309 ACE_TRACE ("ACE_Thru_Task<ACE_SYNCH_USE, TIME_POLICY>::~ACE_Thru_Task");
312 template <ACE_SYNCH_DECL
, class TIME_POLICY
> void
313 ACE_Thru_Task
<ACE_SYNCH_USE
, TIME_POLICY
>::dump () const
315 #if defined (ACE_HAS_DUMP)
316 ACE_TRACE ("ACE_Thru_Task<ACE_SYNCH_USE, TIME_POLICY>::dump");
317 #endif /* ACE_HAS_DUMP */
320 template <ACE_SYNCH_DECL
, class TIME_POLICY
> int
321 ACE_Thru_Task
<ACE_SYNCH_USE
, TIME_POLICY
>::open (void *)
323 ACE_TRACE ("ACE_Thru_Task<ACE_SYNCH_USE, TIME_POLICY>::open");
327 template <ACE_SYNCH_DECL
, class TIME_POLICY
> int
328 ACE_Thru_Task
<ACE_SYNCH_USE
, TIME_POLICY
>::close (u_long
)
330 ACE_TRACE ("ACE_Thru_Task<ACE_SYNCH_USE, TIME_POLICY>::close");
334 template <ACE_SYNCH_DECL
, class TIME_POLICY
> int
335 ACE_Thru_Task
<ACE_SYNCH_USE
, TIME_POLICY
>::svc ()
337 ACE_TRACE ("ACE_Thru_Task<ACE_SYNCH_USE, TIME_POLICY>::svc");
341 template <ACE_SYNCH_DECL
, class TIME_POLICY
> int
342 ACE_Thru_Task
<ACE_SYNCH_USE
, TIME_POLICY
>::put (ACE_Message_Block
*msg
,
345 ACE_TRACE ("ACE_Thru_Task<ACE_SYNCH_USE, TIME_POLICY>::put");
346 return this->put_next (msg
, tv
);
349 template <ACE_SYNCH_DECL
, class TIME_POLICY
> int
350 ACE_Thru_Task
<ACE_SYNCH_USE
, TIME_POLICY
>::init (int, ACE_TCHAR
*[])
352 ACE_TRACE ("ACE_Thru_Task<ACE_SYNCH_USE, TIME_POLICY>::init");
356 template <ACE_SYNCH_DECL
, class TIME_POLICY
> int
357 ACE_Thru_Task
<ACE_SYNCH_USE
, TIME_POLICY
>::info (ACE_TCHAR
**strp
,
360 ACE_TRACE ("ACE_Thru_Task<ACE_SYNCH_USE, TIME_POLICY>::info");
361 const ACE_TCHAR
*name
= this->name ();
363 if (*strp
== 0 && (*strp
= ACE_OS::strdup (name
)) == 0)
366 ACE_OS::strsncpy (*strp
, name
, length
);
367 return static_cast<int> (ACE_OS::strlen (name
));
370 template <ACE_SYNCH_DECL
, class TIME_POLICY
> int
371 ACE_Thru_Task
<ACE_SYNCH_USE
, TIME_POLICY
>::fini ()
373 ACE_TRACE ("ACE_Thru_Task<ACE_SYNCH_USE, TIME_POLICY>::fini");
377 ACE_END_VERSIONED_NAMESPACE_DECL
379 #endif /* ACE_STREAM_MODULES_CPP */