00001 // $Id: SSLSock_IOStream.h 91118 2010-07-17 10:29:57Z mcorino $ 00002 00003 /** 00004 * @file SSLSock_IOStream.h 00005 * 00006 * @author Martin Corino <mcorino@remedy.nl> 00007 */ 00008 00009 #ifndef ACE_IOS_SSLSOCK_IOSTREAM_H 00010 #define ACE_IOS_SSLSOCK_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/SSL/SSL_SOCK_Stream.h" 00021 #include "ace/INet/BidirStreamBuffer.h" 00022 #include "ace/INet/StreamHandler.h" 00023 #include "ace/INet/StreamInterceptor.h" 00024 #include <istream> 00025 #include <ostream> 00026 00027 ACE_BEGIN_VERSIONED_NAMESPACE_DECL 00028 00029 namespace ACE 00030 { 00031 namespace IOS 00032 { 00033 /** 00034 * @class ACE_IOS_SSLSock_StreamBuffer 00035 * 00036 * @brief 00037 * 00038 */ 00039 template <ACE_SYNCH_DECL> 00040 class SSLSock_StreamBufferBase 00041 : public BidirStreamBuffer<StreamHandler<ACE_SSL_SOCK_Stream, ACE_SYNCH_USE> > 00042 { 00043 public: 00044 typedef StreamHandler<ACE_SSL_SOCK_Stream, ACE_SYNCH_USE> stream_type; 00045 00046 SSLSock_StreamBufferBase (stream_type* stream); 00047 virtual ~SSLSock_StreamBufferBase (); 00048 00049 private: 00050 enum 00051 { 00052 BUFFER_SIZE = 1024 00053 }; 00054 }; 00055 00056 /** 00057 * @class ACE_IOS_SSLSock_IOS 00058 * 00059 * @brief 00060 * 00061 */ 00062 template <ACE_SYNCH_DECL> 00063 class SSLSock_IOSBase 00064 : public virtual std::ios 00065 { 00066 public: 00067 typedef SSLSock_StreamBufferBase<ACE_SYNCH_USE> buffer_type; 00068 typedef typename buffer_type::stream_type stream_type; 00069 00070 SSLSock_IOSBase (stream_type* stream); 00071 ~SSLSock_IOSBase (); 00072 00073 buffer_type* rdbuf (); 00074 00075 void close (); 00076 00077 const stream_type& stream () const; 00078 00079 protected: 00080 buffer_type streambuf_; 00081 }; 00082 00083 /** 00084 * @class ACE_IOS_SSLSock_OStream 00085 * 00086 * @brief 00087 * 00088 */ 00089 template <ACE_SYNCH_DECL> 00090 class SSLSock_OStreamBase 00091 : public SSLSock_IOSBase<ACE_SYNCH_USE>, public std::ostream 00092 { 00093 public: 00094 typedef SSLSock_IOSBase<ACE_SYNCH_USE> ios_base; 00095 typedef typename ios_base::stream_type stream_type; 00096 typedef SSLSock_StreamBufferBase<ACE_SYNCH_USE> buffer_type; 00097 00098 explicit SSLSock_OStreamBase(stream_type* stream); 00099 00100 ~SSLSock_OStreamBase(); 00101 00102 void set_interceptor (typename buffer_type::interceptor_type& interceptor); 00103 }; 00104 00105 /** 00106 * @class ACE_IOS_SSLSock_IStream 00107 * 00108 * @brief 00109 * 00110 */ 00111 template <ACE_SYNCH_DECL> 00112 class SSLSock_IStreamBase 00113 : public SSLSock_IOSBase<ACE_SYNCH_USE>, public std::istream 00114 { 00115 public: 00116 typedef SSLSock_IOSBase<ACE_SYNCH_USE> ios_base; 00117 typedef typename ios_base::stream_type stream_type; 00118 typedef SSLSock_StreamBufferBase<ACE_SYNCH_USE> buffer_type; 00119 00120 explicit SSLSock_IStreamBase(stream_type* stream); 00121 00122 ~SSLSock_IStreamBase(); 00123 00124 void set_interceptor (typename buffer_type::interceptor_type& interceptor); 00125 }; 00126 00127 /** 00128 * @class ACE_IOS_SSLSock_IOStream 00129 * 00130 * @brief 00131 * 00132 */ 00133 template <ACE_SYNCH_DECL> 00134 class SSLSock_IOStreamBase 00135 : public SSLSock_IOSBase<ACE_SYNCH_USE>, public std::iostream 00136 { 00137 public: 00138 typedef SSLSock_IOSBase<ACE_SYNCH_USE> ios_base; 00139 typedef typename ios_base::stream_type stream_type; 00140 typedef SSLSock_StreamBufferBase<ACE_SYNCH_USE> buffer_type; 00141 00142 explicit SSLSock_IOStreamBase(stream_type* stream); 00143 00144 ~SSLSock_IOStreamBase(); 00145 00146 void set_interceptor (typename buffer_type::interceptor_type& interceptor); 00147 }; 00148 00149 typedef SSLSock_StreamBufferBase<ACE_NULL_SYNCH> SSLSock_StreamBuffer; 00150 typedef SSLSock_IOSBase<ACE_NULL_SYNCH> SSLSock_IOS; 00151 typedef SSLSock_IStreamBase<ACE_NULL_SYNCH> SSLSock_IStream; 00152 typedef SSLSock_OStreamBase<ACE_NULL_SYNCH> SSLSock_OStream; 00153 typedef SSLSock_IOStreamBase<ACE_NULL_SYNCH> SSLSock_IOStream; 00154 00155 } 00156 } 00157 00158 ACE_END_VERSIONED_NAMESPACE_DECL 00159 00160 #if defined (ACE_TEMPLATES_REQUIRE_SOURCE) 00161 #include "ace/INet/SSLSock_IOStream.cpp" 00162 #endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ 00163 00164 #if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) 00165 #pragma implementation ("SSLSock_IOStream.cpp") 00166 #endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ 00167 00168 #include /**/ "ace/post.h" 00169 #endif /* ACE_IOS_SSLSOCK_IOSTREAM_H */