// Stream_Modules.cpp // $Id$ #if !defined (ACE_STREAM_MODULES_C) #define ACE_STREAM_MODULES_C #define ACE_BUILD_DLL #include "ace/Stream_Modules.h" #if !defined (__ACE_INLINE__) #include "ace/Stream_Modules.i" #endif /* __ACE_INLINE__ */ ACE_ALLOC_HOOK_DEFINE(ACE_Stream_Head) template ACE_Stream_Head::ACE_Stream_Head (void) { ACE_TRACE ("ACE_Stream_Head::ACE_Stream_Head"); } template ACE_Stream_Head::~ACE_Stream_Head (void) { ACE_TRACE ("ACE_Stream_Head::~ACE_Stream_Head"); } template void ACE_Stream_Head::dump (void) const { ACE_TRACE ("ACE_Stream_Head::dump"); } /* ACE_Module that act as the head and tail of a Stream. */ template int ACE_Stream_Head::open (void *) { ACE_TRACE ("ACE_Stream_Head::open"); return 0; } template int ACE_Stream_Head::close (u_long) { ACE_TRACE ("ACE_Stream_Head::close"); return 0; } template int ACE_Stream_Head::svc (void) { ACE_TRACE ("ACE_Stream_Head::svc"); return -1; } template int ACE_Stream_Head::control (ACE_Message_Block *mb) { ACE_TRACE ("ACE_Stream_Head::control"); ACE_IO_Cntl_Msg *ioc = (ACE_IO_Cntl_Msg *) mb->rd_ptr (); ACE_IO_Cntl_Msg::ACE_IO_Cntl_Cmds cmd; switch (cmd = ioc->cmd ()) { case ACE_IO_Cntl_Msg::SET_LWM: case ACE_IO_Cntl_Msg::SET_HWM: this->water_marks (cmd, *(size_t *) mb->cont ()->rd_ptr ()); ioc->rval (0); break; default: return 0; } return ioc->rval (); } /* Performs canonical flushing at the ACE_Stream Head */ template int ACE_Stream_Head::canonical_flush (ACE_Message_Block *mb) { ACE_TRACE ("ACE_Stream_Head::canonical_flush"); char *cp = mb->rd_ptr (); if (*cp & ACE_Task_Flags::ACE_FLUSHR) { this->flush (ACE_Task_Flags::ACE_FLUSHALL); *cp &= ~ACE_Task_Flags::ACE_FLUSHR; } if (*cp & ACE_Task_Flags::ACE_FLUSHW) return this->reply (mb); else delete mb; return 0; } template int ACE_Stream_Head::put (ACE_Message_Block *mb, ACE_Time_Value *tv) { ACE_TRACE ("ACE_Stream_Head::put"); int res = 0; if (mb->msg_type () == ACE_Message_Block::MB_IOCTL && (res = this->control (mb)) == -1) return res; if (this->is_writer ()) { return this->put_next (mb, tv); } else /* this->is_reader () */ { switch (mb->msg_type ()) { case ACE_Message_Block::MB_FLUSH: return this->canonical_flush (mb); default: break; } return this->putq (mb, tv); } } template int ACE_Stream_Head::init (int, char *[]) { ACE_TRACE ("ACE_Stream_Head::init"); return 0; } template int ACE_Stream_Head::info (char **strp, size_t length) const { ACE_TRACE ("ACE_Stream_Head::info"); const char *name = this->name (); if (*strp == 0 && (*strp = ACE_OS::strdup (name)) == 0) return -1; else ACE_OS::strncpy (*strp, name, length); return ACE_OS::strlen (name); } template int ACE_Stream_Head::fini (void) { ACE_TRACE ("ACE_Stream_Head::fini"); return 0; } ACE_ALLOC_HOOK_DEFINE(ACE_Stream_Tail) template ACE_Stream_Tail::ACE_Stream_Tail (void) { ACE_TRACE ("ACE_Stream_Tail::ACE_Stream_Tail"); } template ACE_Stream_Tail::~ACE_Stream_Tail (void) { ACE_TRACE ("ACE_Stream_Tail::~ACE_Stream_Tail"); } template void ACE_Stream_Tail::dump (void) const { ACE_TRACE ("ACE_Stream_Tail::dump"); } template int ACE_Stream_Tail::open (void *) { ACE_TRACE ("ACE_Stream_Tail::open"); return 0; } template int ACE_Stream_Tail::close (u_long) { ACE_TRACE ("ACE_Stream_Tail::close"); return 0; } template int ACE_Stream_Tail::svc (void) { ACE_TRACE ("ACE_Stream_Tail::svc"); return -1; } template int ACE_Stream_Tail::control (ACE_Message_Block *mb) { ACE_TRACE ("ACE_Stream_Tail::control"); ACE_IO_Cntl_Msg *ioc = (ACE_IO_Cntl_Msg *) mb->rd_ptr (); ACE_IO_Cntl_Msg::ACE_IO_Cntl_Cmds cmd; switch (cmd = ioc->cmd ()) { case ACE_IO_Cntl_Msg::SET_LWM: case ACE_IO_Cntl_Msg::SET_HWM: { size_t size = *(size_t *) mb->cont ()->rd_ptr (); this->water_marks (cmd, size); this->sibling ()->water_marks (cmd, size); ioc->rval (0); break; } default: mb->msg_type (ACE_Message_Block::MB_IOCNAK); } return this->reply (mb); } /* Perform flush algorithm as though we were the driver */ template int ACE_Stream_Tail::canonical_flush (ACE_Message_Block *mb) { ACE_TRACE ("ACE_Stream_Tail::canonical_flush"); char *cp = mb->rd_ptr (); if (*cp & ACE_Task_Flags::ACE_FLUSHW) { this->flush (ACE_Task_Flags::ACE_FLUSHALL); *cp &= ~ACE_Task_Flags::ACE_FLUSHW; } if (*cp & ACE_Task_Flags::ACE_FLUSHR) { this->sibling ()->flush (ACE_Task_Flags::ACE_FLUSHALL); return this->reply (mb); } else delete mb; return 0; } template int ACE_Stream_Tail::put (ACE_Message_Block *mb, ACE_Time_Value * ) { ACE_TRACE ("ACE_Stream_Tail::put"); if (this->is_writer ()) { switch (mb->msg_type ()) { case ACE_Message_Block::MB_IOCTL: return this->control (mb); /* NOTREACHED */ default: delete mb; } } return -1; } template int ACE_Stream_Tail::init (int, char *[]) { ACE_TRACE ("ACE_Stream_Tail::init"); return 0; } template int ACE_Stream_Tail::info (char **strp, size_t length) const { ACE_TRACE ("ACE_Stream_Tail::info"); const char *name = this->name (); if (*strp == 0 && (*strp = ACE_OS::strdup (name)) == 0) return -1; else ACE_OS::strncpy (*strp, name, length); return ACE_OS::strlen (name); } template int ACE_Stream_Tail::fini (void) { ACE_TRACE ("ACE_Stream_Tail::fini"); return 0; } ACE_ALLOC_HOOK_DEFINE(ACE_Thru_Task) template ACE_Thru_Task::ACE_Thru_Task (void) { ACE_TRACE ("ACE_Thru_Task::ACE_Thru_Task"); } template ACE_Thru_Task::~ACE_Thru_Task (void) { ACE_TRACE ("ACE_Thru_Task::~ACE_Thru_Task"); } template void ACE_Thru_Task::dump (void) const { ACE_TRACE ("ACE_Thru_Task::dump"); } template int ACE_Thru_Task::open (void *) { ACE_TRACE ("ACE_Thru_Task::open"); return 0; } template int ACE_Thru_Task::close (u_long) { ACE_TRACE ("ACE_Thru_Task::close"); return 0; } template int ACE_Thru_Task::svc (void) { ACE_TRACE ("ACE_Thru_Task::svc"); return -1; } template int ACE_Thru_Task::put (ACE_Message_Block *msg, ACE_Time_Value *tv) { ACE_TRACE ("ACE_Thru_Task::put"); return this->put_next (msg, tv); } template int ACE_Thru_Task::init (int, char *[]) { ACE_TRACE ("ACE_Thru_Task::init"); return 0; } template int ACE_Thru_Task::info (char **strp, size_t length) const { ACE_TRACE ("ACE_Thru_Task::info"); const char *name = this->name (); if (*strp == 0 && (*strp = ACE_OS::strdup (name)) == 0) return -1; else ACE_OS::strncpy (*strp, name, length); return ACE_OS::strlen (name); } template int ACE_Thru_Task::fini (void) { ACE_TRACE ("ACE_Thru_Task::fini"); return 0; } #endif /* ACE_STREAM_MODULES_C */