diff options
Diffstat (limited to 'ace')
-rw-r--r-- | ace/IOStream_T.cpp | 51 | ||||
-rw-r--r-- | ace/IOStream_T.h | 44 | ||||
-rw-r--r-- | ace/IOStream_T.i | 13 |
3 files changed, 42 insertions, 66 deletions
diff --git a/ace/IOStream_T.cpp b/ace/IOStream_T.cpp index 5bf9ba9670d..a0b868a5513 100644 --- a/ace/IOStream_T.cpp +++ b/ace/IOStream_T.cpp @@ -11,7 +11,7 @@ # pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ -//ACE_RCSID(ace, IOStream_T, "$Id$") +ACE_RCSID(ace, IOStream_T, "$Id$") #if !defined (ACE_LACKS_ACE_IOSTREAM) @@ -63,32 +63,6 @@ ACE_Streambuf_T<STREAM>::ACE_Streambuf_T (STREAM *peer, #endif /* ! ACE_LACKS_LINEBUFFERED_STREAMBUF */ } -template <class STREAM> -ACE_Streambuf_T<STREAM>::ACE_Streambuf_T (u_int streambuf_size, - int io_mode) - : ACE_Streambuf (streambuf_size, io_mode) -{ - ACE_NEW (peer_, STREAM ); - - // A streambuf allows for unbuffered IO where every character is - // read as requested and written as provided. To me, this seems - // terribly inefficient for socket-type operations, so I've disabled - // it. All of the work would be done by the underflow/overflow - // functions anyway and I haven't implemented anything there to - // support unbuffered IO. - -#if !defined (ACE_LACKS_UNBUFFERED_STREAMBUF) - this->unbuffered (0); -#endif /* ! ACE_LACKS_UNBUFFERED_STREAMBUF */ - - // Linebuffered is similar to unbuffered. Again, I don't have any - // need for this and I don't see the advantage. I believe this - // would have to be supported by underflow/overflow to be effective. -#if !defined (ACE_LACKS_LINEBUFFERED_STREAMBUF) - this->linebuffered (0); -#endif /* ! ACE_LACKS_LINEBUFFERED_STREAMBUF */ -} - // The typical constructor. This will initiailze your STREAM and then // setup the iostream baseclass to use a custom streambuf based on // STREAM. @@ -96,22 +70,32 @@ ACE_Streambuf_T<STREAM>::ACE_Streambuf_T (u_int streambuf_size, template <class STREAM> ACE_IOStream<STREAM>::ACE_IOStream (STREAM &stream, u_int streambuf_size) - : STREAM (stream), - ACE_Streambuf_T<STREAM> ( this, streambuf_size ), - iostream ((ACE_Streambuf_T<STREAM> *)this) + : iostream (0), + STREAM (stream) { + ACE_NEW (streambuf_, + ACE_Streambuf_T<STREAM> ((STREAM *) this, + streambuf_size)); + iostream::init (this->streambuf_); } template <class STREAM> ACE_IOStream<STREAM>::ACE_IOStream (u_int streambuf_size) - : ACE_Streambuf_T<STREAM> ( this, streambuf_size ), - iostream ((ACE_Streambuf_T<STREAM> *)this) + : iostream (0) { + ACE_NEW (this->streambuf_, + ACE_Streambuf_T<STREAM> ((STREAM *) this, + streambuf_size)); + iostream::init (this->streambuf_); } +// We have to get rid of the streambuf_ ourselves since we gave it to +// iostream () + template <class STREAM> ACE_IOStream<STREAM>::~ACE_IOStream (void) { + delete this->streambuf_; } // The only ambituity in the multiple inheritance is the close () @@ -126,7 +110,7 @@ ACE_IOStream<STREAM>::close (void) template <class STREAM> ACE_IOStream<STREAM> & ACE_IOStream<STREAM>::operator>> (ACE_Time_Value *&tv) { - ACE_Time_Value *old_tv = ACE_Streambuf_T<STREAM>::recv_timeout (tv); + ACE_Time_Value *old_tv = this->streambuf_->recv_timeout (tv); tv = old_tv; return *this; } @@ -226,4 +210,3 @@ operator<< (STREAM &stream, #endif /* ACE_HAS_STRING_CLASS */ #endif /* ACE_LACKS_ACE_IOSTREAM */ #endif /* ACE_IOSTREAM_T_C */ - diff --git a/ace/IOStream_T.h b/ace/IOStream_T.h index f311c34237d..86e0c6bf645 100644 --- a/ace/IOStream_T.h +++ b/ace/IOStream_T.h @@ -1,7 +1,7 @@ /* -*- C++ -*- */ // $Id$ -//============================================================================ +// ============================================================================ // // = LIBRARY // ace @@ -17,7 +17,7 @@ // Instead, it should #include "ace/IOStream.h". That's because // we only put some conditional compilations in that file. // -//============================================================================ +// ============================================================================ #ifndef ACE_IOSTREAM_T_H #define ACE_IOSTREAM_T_H @@ -31,10 +31,8 @@ #if !defined (ACE_LACKS_ACE_IOSTREAM) #if defined (ACE_HAS_STRING_CLASS) -template <class STREAM> STREAM & operator>> (STREAM &stream, -ACE_Quoted_String &str); -template <class STREAM> STREAM & operator<< (STREAM &stream, -ACE_Quoted_String &str); +template <class STREAM> STREAM & operator>> (STREAM &stream, ACE_Quoted_String &str); +template <class STREAM> STREAM & operator<< (STREAM &stream, ACE_Quoted_String &str); #endif /* defined (ACE_HAS_STRING_CLASS) */ template <class STREAM> @@ -49,12 +47,6 @@ public: // other streambuf objects, we can be input-only, output-only or // both. - ACE_Streambuf_T (u_int streambuf_size = ACE_STREAMBUF_SIZE, - int io_mode = ios::in | ios::out); - // We will create the STREAM by ourselves. Like - // other streambuf objects, we can be input-only, output-only or - // both. - virtual ssize_t send (char *buf, ssize_t len); virtual ssize_t recv (char *buf, @@ -79,12 +71,7 @@ protected: }; template <class STREAM> -class ACE_IOStream : public STREAM, - protected ACE_Streambuf_T<STREAM>, - // This is where all of the action takes place. The - // ACE_Streambuf_T<STREAM> - // is the interface to the underlying STREAM. - public iostream +class ACE_IOStream : public iostream, public STREAM { // = TITLE // A template adapter for creating an iostream-like object using @@ -128,6 +115,8 @@ public: // on STREAM. virtual ~ACE_IOStream (void); + // We have to get rid of the <streambuf_> ourselves since we gave it + // to the <iostream> base class; virtual int close (void); // The only ambituity in the multiple inheritance is the <close> @@ -202,10 +191,8 @@ public: virtual void osfx (void) { if (flags() & unitbuf) flush(); } #else #if defined (__GNUC__) - // Optimized ipfx(0) - virtual int ipfx0(void) { return iostream::ipfx0 (); } - // Optimized ipfx(1) - virtual int ipfx1(void) { return iostream::ipfx1(); } + virtual int ipfx0(void) { return iostream::ipfx0 (); } // Optimized ipfx(0) + virtual int ipfx1(void) { return iostream::ipfx1(); } // Optimized ipfx(1) #else virtual int ipfx0(void) { return iostream::ipfx (0); } virtual int ipfx1(void) { return iostream::ipfx (1); } @@ -220,14 +207,19 @@ public: // Allow the programmer to provide a timeout for read operations. // Give it a pointer to NULL to block forever. +protected: + ACE_Streambuf_T<STREAM> *streambuf_; + // This is where all of the action takes place. The streambuf_ is + // the interface to the underlying STREAM. + private: // = Private methods. // We move these into the private section so that they cannot be // used by the application programmer. This is necessary because - // the ACE_Streambuf_T<STREAM> will be buffering IO on the STREAM object. - // If these functions were used in your program, there is a danger of - // getting the datastream out of sync. + // streambuf_ will be buffering IO on the STREAM object. If these + // functions were used in your program, there is a danger of getting + // the datastream out of sync. ACE_UNIMPLEMENTED_FUNC (ssize_t send (...)) ACE_UNIMPLEMENTED_FUNC (ssize_t recv (...)) ACE_UNIMPLEMENTED_FUNC (ssize_t send_n (...)) @@ -279,7 +271,7 @@ protected: #endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ #if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) -#pragma implementation "IOStream_T.cpp" +#pragma implementation ("IOStream_T.cpp") #endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ #endif /* ACE_LACKS_ACE_IOSTREAM */ #endif /* ACE_IOSTREAM_T_H */ diff --git a/ace/IOStream_T.i b/ace/IOStream_T.i index 67d99c8080a..c145eb52cc3 100644 --- a/ace/IOStream_T.i +++ b/ace/IOStream_T.i @@ -53,17 +53,19 @@ template <class STREAM> ACE_INLINE int ACE_IOStream<STREAM>::eof (void) const { // Get the timeout value of the streambuf - ACE_Time_Value *timeout = ACE_Streambuf_T<STREAM>::recv_timeout (0); + ACE_Time_Value *timeout = this->streambuf_->recv_timeout (0); // Reset the timeout value of the streambuf. - (void) ACE_Streambuf_T<STREAM>::recv_timeout (timeout); + (void) this->streambuf_->recv_timeout (timeout); char c; - int rval = ACE_Streambuf_T<STREAM>::recv_n (&c, sizeof c, MSG_PEEK, -timeout); + int rval = this->streambuf_->recv_n (&c, + sizeof c, + MSG_PEEK, + timeout); // Timeout, not an eof - if (ACE_Streambuf_T<STREAM>::timeout()) + if (this->streambuf_->timeout()) return 0; // No timeout, got enough data: not eof @@ -156,4 +158,3 @@ ACE_SOCK_Dgram_SC<STREAM>::get_remote_addr (ACE_INET_Addr &addr) const addr = peer_; return 0; } - |