00001 // $Id: Sock_IOStream.h 90789 2010-06-23 10:30:53Z mcorino $ 00002 00003 /** 00004 * @file Sock_IOStream.h 00005 * 00006 * @author Martin Corino <mcorino@remedy.nl> 00007 */ 00008 00009 #ifndef ACE_IOS_SOCK_IOSTREAM_H 00010 #define ACE_IOS_SOCK_IOSTREAM_H 00011 00012 #include /**/ "ace/pre.h" 00013 00014 #include /**/ "ace/config-all.h" 00015 00016 #if !defined (ACE_LACKS_PRAGMA_ONCE) 00017 # pragma once 00018 #endif /* ACE_LACKS_PRAGMA_ONCE */ 00019 00020 #include "ace/INet/BidirStreamBuffer.h" 00021 #include "ace/INet/StreamHandler.h" 00022 #include "ace/INet/StreamInterceptor.h" 00023 #include <istream> 00024 #include <ostream> 00025 00026 ACE_BEGIN_VERSIONED_NAMESPACE_DECL 00027 00028 namespace ACE 00029 { 00030 namespace IOS 00031 { 00032 /** 00033 * @class ACE_IOS_Sock_StreamBuffer 00034 * 00035 * @brief 00036 * 00037 */ 00038 template <ACE_SYNCH_DECL> 00039 class Sock_StreamBufferBase 00040 : public BidirStreamBuffer<StreamHandler<ACE_SOCK_STREAM, ACE_SYNCH_USE> > 00041 { 00042 public: 00043 typedef StreamHandler<ACE_SOCK_STREAM, ACE_SYNCH_USE> stream_type; 00044 00045 Sock_StreamBufferBase (stream_type* stream); 00046 virtual ~Sock_StreamBufferBase (); 00047 00048 private: 00049 enum 00050 { 00051 BUFFER_SIZE = 1024 00052 }; 00053 }; 00054 00055 /** 00056 * @class ACE_IOS_Sock_IOS 00057 * 00058 * @brief 00059 * 00060 */ 00061 template <ACE_SYNCH_DECL> 00062 class Sock_IOSBase 00063 : public virtual std::ios 00064 { 00065 public: 00066 typedef Sock_StreamBufferBase<ACE_SYNCH_USE> buffer_type; 00067 typedef typename buffer_type::stream_type stream_type; 00068 00069 Sock_IOSBase (stream_type* stream); 00070 ~Sock_IOSBase (); 00071 00072 buffer_type* rdbuf (); 00073 00074 void close (); 00075 00076 const stream_type& stream () const; 00077 00078 protected: 00079 buffer_type streambuf_; 00080 }; 00081 00082 /** 00083 * @class ACE_IOS_Sock_OStream 00084 * 00085 * @brief 00086 * 00087 */ 00088 template <ACE_SYNCH_DECL> 00089 class Sock_OStreamBase 00090 : public Sock_IOSBase<ACE_SYNCH_USE>, public std::ostream 00091 { 00092 public: 00093 typedef Sock_IOSBase<ACE_SYNCH_USE> ios_base; 00094 typedef typename ios_base::stream_type stream_type; 00095 typedef Sock_StreamBufferBase<ACE_SYNCH_USE> buffer_type; 00096 00097 explicit Sock_OStreamBase(stream_type* stream); 00098 00099 ~Sock_OStreamBase(); 00100 00101 void set_interceptor (typename buffer_type::interceptor_type& interceptor); 00102 }; 00103 00104 /** 00105 * @class ACE_IOS_Sock_IStream 00106 * 00107 * @brief 00108 * 00109 */ 00110 template <ACE_SYNCH_DECL> 00111 class Sock_IStreamBase 00112 : public Sock_IOSBase<ACE_SYNCH_USE>, public std::istream 00113 { 00114 public: 00115 typedef Sock_IOSBase<ACE_SYNCH_USE> ios_base; 00116 typedef typename ios_base::stream_type stream_type; 00117 typedef Sock_StreamBufferBase<ACE_SYNCH_USE> buffer_type; 00118 00119 explicit Sock_IStreamBase(stream_type* stream); 00120 00121 ~Sock_IStreamBase(); 00122 00123 void set_interceptor (typename buffer_type::interceptor_type& interceptor); 00124 }; 00125 00126 /** 00127 * @class ACE_IOS_Sock_IOStream 00128 * 00129 * @brief 00130 * 00131 */ 00132 template <ACE_SYNCH_DECL> 00133 class Sock_IOStreamBase 00134 : public Sock_IOSBase<ACE_SYNCH_USE>, public std::iostream 00135 { 00136 public: 00137 typedef Sock_IOSBase<ACE_SYNCH_USE> ios_base; 00138 typedef typename ios_base::stream_type stream_type; 00139 typedef Sock_StreamBufferBase<ACE_SYNCH_USE> buffer_type; 00140 00141 explicit Sock_IOStreamBase(stream_type* stream); 00142 00143 ~Sock_IOStreamBase(); 00144 00145 void set_interceptor (typename buffer_type::interceptor_type& interceptor); 00146 }; 00147 00148 typedef Sock_StreamBufferBase<ACE_NULL_SYNCH> Sock_StreamBuffer; 00149 typedef Sock_IOSBase<ACE_NULL_SYNCH> Sock_IOS; 00150 typedef Sock_IStreamBase<ACE_NULL_SYNCH> Sock_IStream; 00151 typedef Sock_OStreamBase<ACE_NULL_SYNCH> Sock_OStream; 00152 typedef Sock_IOStreamBase<ACE_NULL_SYNCH> Sock_IOStream; 00153 00154 } 00155 } 00156 00157 ACE_END_VERSIONED_NAMESPACE_DECL 00158 00159 #if defined (ACE_TEMPLATES_REQUIRE_SOURCE) 00160 #include "ace/INet/Sock_IOStream.cpp" 00161 #endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ 00162 00163 #if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) 00164 #pragma implementation ("Sock_IOStream.cpp") 00165 #endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ 00166 00167 #include /**/ "ace/post.h" 00168 #endif /* ACE_IOS_SOCK_IOSTREAM_H */