summaryrefslogtreecommitdiff
path: root/ACE/protocols/ace/INet/Sock_IOStream.h
blob: ddd101c745368d191221df8fb00177f933a8f915 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
/**
 * @file Sock_IOStream.h
 *
 * @author Martin Corino <mcorino@remedy.nl>
 */

#ifndef ACE_IOS_SOCK_IOSTREAM_H
#define ACE_IOS_SOCK_IOSTREAM_H

#include /**/ "ace/pre.h"

#include /**/ "ace/config-all.h"

#if !defined (ACE_LACKS_PRAGMA_ONCE)
# pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */

#include "ace/INet/BidirStreamBuffer.h"
#include "ace/INet/StreamHandler.h"
#include "ace/INet/StreamInterceptor.h"
#include <istream>
#include <ostream>

ACE_BEGIN_VERSIONED_NAMESPACE_DECL

namespace ACE
  {
    namespace IOS
      {
        /**
        * @class ACE_IOS_Sock_StreamBuffer
        *
        * @brief
        *
        */
        template <ACE_SYNCH_DECL>
        class Sock_StreamBufferBase
          : public BidirStreamBuffer<StreamHandler<ACE_SOCK_STREAM, ACE_SYNCH_USE> >
          {
            public:
              typedef StreamHandler<ACE_SOCK_STREAM, ACE_SYNCH_USE> stream_type;

              Sock_StreamBufferBase (stream_type* stream);
              virtual ~Sock_StreamBufferBase ();

            private:
              enum
              {
                BUFFER_SIZE = 1024
              };
          };

        /**
        * @class ACE_IOS_Sock_IOS
        *
        * @brief
        *
        */
        template <ACE_SYNCH_DECL>
        class Sock_IOSBase
          : public virtual std::ios
          {
            public:
              typedef Sock_StreamBufferBase<ACE_SYNCH_USE> buffer_type;
              typedef typename buffer_type::stream_type stream_type;

              Sock_IOSBase (stream_type* stream);
              ~Sock_IOSBase ();

              buffer_type* rdbuf ();

              void close ();

              const stream_type& stream () const;

            protected:
              buffer_type streambuf_;
          };

        /**
        * @class ACE_IOS_Sock_OStream
        *
        * @brief
        *
        */
        template <ACE_SYNCH_DECL>
        class Sock_OStreamBase
          : public Sock_IOSBase<ACE_SYNCH_USE>, public std::ostream
          {
            public:
              typedef Sock_IOSBase<ACE_SYNCH_USE> ios_base;
              typedef typename ios_base::stream_type stream_type;
              typedef Sock_StreamBufferBase<ACE_SYNCH_USE> buffer_type;

              explicit Sock_OStreamBase(stream_type* stream);

              ~Sock_OStreamBase();

              buffer_type* rdbuf ()
              { return ios_base::rdbuf (); }

              void set_interceptor (typename buffer_type::interceptor_type& interceptor);
          };

        /**
        * @class ACE_IOS_Sock_IStream
        *
        * @brief
        *
        */
        template <ACE_SYNCH_DECL>
        class Sock_IStreamBase
          : public Sock_IOSBase<ACE_SYNCH_USE>, public std::istream
          {
            public:
              typedef Sock_IOSBase<ACE_SYNCH_USE> ios_base;
              typedef typename ios_base::stream_type stream_type;
              typedef Sock_StreamBufferBase<ACE_SYNCH_USE> buffer_type;

              explicit Sock_IStreamBase(stream_type* stream);

              buffer_type* rdbuf ()
              { return ios_base::rdbuf (); }

              ~Sock_IStreamBase();

              void set_interceptor (typename buffer_type::interceptor_type& interceptor);
          };

        /**
        * @class ACE_IOS_Sock_IOStream
        *
        * @brief
        *
        */
        template <ACE_SYNCH_DECL>
        class Sock_IOStreamBase
          : public Sock_IOSBase<ACE_SYNCH_USE>, public std::iostream
          {
            public:
              typedef Sock_IOSBase<ACE_SYNCH_USE> ios_base;
              typedef typename ios_base::stream_type stream_type;
              typedef Sock_StreamBufferBase<ACE_SYNCH_USE> buffer_type;

              explicit Sock_IOStreamBase(stream_type* stream);

              buffer_type* rdbuf ()
              { return ios_base::rdbuf (); }

              ~Sock_IOStreamBase();

              void set_interceptor (typename buffer_type::interceptor_type& interceptor);
          };

        typedef Sock_StreamBufferBase<ACE_NULL_SYNCH> Sock_StreamBuffer;
        typedef Sock_IOSBase<ACE_NULL_SYNCH> Sock_IOS;
        typedef Sock_IStreamBase<ACE_NULL_SYNCH> Sock_IStream;
        typedef Sock_OStreamBase<ACE_NULL_SYNCH> Sock_OStream;
        typedef Sock_IOStreamBase<ACE_NULL_SYNCH> Sock_IOStream;
      }
  }

ACE_END_VERSIONED_NAMESPACE_DECL

#if defined (ACE_TEMPLATES_REQUIRE_SOURCE)
#include "ace/INet/Sock_IOStream.cpp"
#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */

#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA)
#pragma implementation ("Sock_IOStream.cpp")
#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */

#include /**/ "ace/post.h"
#endif /* ACE_IOS_SOCK_IOSTREAM_H */