Merge pull request #1844 from jrw972/monterey
[ACE_TAO.git] / ACE / apps / JAWS2 / JAWS / Jaws_IO.h
blob9bc060aaa5ce0182f809a52c616bc506a62bc823
1 /* -*- c++ -*- */
3 //=============================================================================
4 /**
5 * @file Jaws_IO.h
7 * @author James Hu
8 */
9 //=============================================================================
12 #ifndef JAWS_IO_H
13 #define JAWS_IO_H
15 #include "ace/ACE.h"
17 #if !defined (ACE_LACKS_PRAGMA_ONCE)
18 # pragma once
19 #endif /* ACE_LACKS_PRAGMA_ONCE */
21 #include "ace/Asynch_IO.h"
22 #include "ace/SOCK_Stream.h"
23 #include "ace/Singleton.h"
24 #include "ace/Synch_Traits.h"
26 #include "JAWS/Export.h"
28 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
29 class ACE_Message_Block;
30 ACE_END_VERSIONED_NAMESPACE_DECL
32 class JAWS_IO_Handler;
33 class JAWS_IO_Acceptor;
35 /**
36 * @class JAWS_IO
38 * @brief This class defines the abstract interface for an I/O class in
39 * the context of Web-likes servers
41 * An I/O class should have the following interface. Derived
42 * classes will define the exactly how the I/O will take place
43 * (Asynchronous, Synchronous, Reactive)
45 class JAWS_Export JAWS_IO
47 public:
48 JAWS_IO (void);
49 virtual ~JAWS_IO (void);
51 // void acceptor (JAWS_IO_Acceptor *acceptor);
52 // void handler (JAWS_IO_Handler *handler);
53 // void handle (ACE_HANDLE h);
54 // ACE_HANDLE handle (void);
56 // James, please add documentation here.
58 /// accept a passive connection
59 virtual void accept (JAWS_IO_Handler *ioh,
60 ACE_Message_Block *mb = 0,
61 unsigned int size = 0) = 0;
63 /// read from the handle size bytes into the message block.
64 virtual void read (JAWS_IO_Handler *ioh,
65 ACE_Message_Block *mb,
66 unsigned int size) = 0;
68 /// send header, filename, trailer to the handle.
69 virtual void transmit_file (JAWS_IO_Handler *ioh,
70 ACE_HANDLE file,
71 const char *header,
72 unsigned int header_size,
73 const char *trailer,
74 unsigned int trailer_size) = 0;
76 /// send header, filename, trailer to the handle.
77 virtual void transmit_file (JAWS_IO_Handler *ioh,
78 const char *filename,
79 const char *header,
80 unsigned int header_size,
81 const char *trailer,
82 unsigned int trailer_size) = 0;
84 /// read data from the handle and store in filename.
85 virtual void receive_file (JAWS_IO_Handler *ioh,
86 const char *filename,
87 void *initial_data,
88 unsigned int initial_data_length,
89 unsigned int entire_length) = 0;
91 /// send a confirmation message to the handle.
92 virtual void send_confirmation_message (JAWS_IO_Handler *ioh,
93 const char *buffer,
94 unsigned int length) = 0;
96 /// send an error message to the handle.
97 virtual void send_error_message (JAWS_IO_Handler *ioh,
98 const char *buffer,
99 unsigned int length) = 0;
101 protected:
102 ACE_HANDLE handle_;
103 JAWS_IO_Handler *handler_;
104 ACE_INET_Addr *inet_addr_;
105 JAWS_IO_Acceptor *acceptor_;
109 * @class JAWS_Synch_IO
111 * @brief This class defines the interface for a Synchronous I/O class.
113 class JAWS_Export JAWS_Synch_IO : public JAWS_IO
115 public:
116 JAWS_Synch_IO (void);
118 virtual ~JAWS_Synch_IO (void);
120 virtual void accept (JAWS_IO_Handler *ioh,
121 ACE_Message_Block *mb = 0,
122 unsigned int size = 0);
124 virtual void read (JAWS_IO_Handler *ioh,
125 ACE_Message_Block *mb,
126 unsigned int size);
128 virtual void transmit_file (JAWS_IO_Handler *ioh,
129 ACE_HANDLE handle,
130 const char *header,
131 unsigned int header_size,
132 const char *trailer,
133 unsigned int trailer_size);
135 virtual void transmit_file (JAWS_IO_Handler *ioh,
136 const char *filename,
137 const char *header,
138 unsigned int header_size,
139 const char *trailer,
140 unsigned int trailer_size);
142 virtual void receive_file (JAWS_IO_Handler *ioh,
143 const char *filename,
144 void *initial_data,
145 unsigned int initial_data_length,
146 unsigned int entire_length);
148 virtual void send_confirmation_message (JAWS_IO_Handler *ioh,
149 const char *buffer,
150 unsigned int length);
152 virtual void send_error_message (JAWS_IO_Handler *ioh,
153 const char *buffer,
154 unsigned int length);
156 protected:
157 virtual void send_message (JAWS_IO_Handler *ioh,
158 const char *buffer,
159 unsigned int length);
162 typedef ACE_Singleton<JAWS_Synch_IO, ACE_SYNCH_MUTEX>
163 JAWS_Synch_IO_Singleton;
165 // This only works on asynch I/O-capable systems.
166 #if defined (ACE_HAS_WIN32_OVERLAPPED_IO) || defined (ACE_HAS_AIO_CALLS)
169 * @class JAWS_Asynch_IO
171 * @brief This class defines the interface for a Asynchronous I/O class.
173 class JAWS_Export JAWS_Asynch_IO : public JAWS_IO
175 public:
176 JAWS_Asynch_IO (void);
178 virtual ~JAWS_Asynch_IO (void);
180 virtual void accept (JAWS_IO_Handler *ioh,
181 ACE_Message_Block *mb = 0,
182 unsigned int size = 0);
184 virtual void read (JAWS_IO_Handler *ioh,
185 ACE_Message_Block *mb,
186 unsigned int size);
188 virtual void transmit_file (JAWS_IO_Handler *ioh,
189 ACE_HANDLE handle,
190 const char *header,
191 unsigned int header_size,
192 const char *trailer,
193 unsigned int trailer_size);
195 virtual void transmit_file (JAWS_IO_Handler *ioh,
196 const char *filename,
197 const char *header,
198 unsigned int header_size,
199 const char *trailer,
200 unsigned int trailer_size);
202 virtual void receive_file (JAWS_IO_Handler *ioh,
203 const char *filename,
204 void *initial_data,
205 unsigned int initial_data_length,
206 unsigned int entire_length);
208 virtual void send_confirmation_message (JAWS_IO_Handler *ioh,
209 const char *buffer,
210 unsigned int length);
212 virtual void send_error_message (JAWS_IO_Handler *ioh,
213 const char *buffer,
214 unsigned int length);
216 #ifdef ACE_LYNXOS_MAJOR
217 #ifdef ERROR_MESSAGE
218 #undef ERROR_MESSAGE
219 #endif /* ERROR_MESSAGE */
220 #endif /* ACE_LYNXOS_MAJOR */
222 enum Message_Types
224 CONFIRMATION,
225 ERROR_MESSAGE
228 protected:
230 virtual void send_message (JAWS_IO_Handler *ioh,
231 const char *buffer,
232 unsigned int length,
233 long act);
236 typedef ACE_Singleton<JAWS_Asynch_IO, ACE_SYNCH_MUTEX>
237 JAWS_Asynch_IO_Singleton;
240 * @class JAWS_Asynch2_IO
241 This version of Asynch_IO has a do nothing accept() implementation.
243 class JAWS_Export JAWS_Asynch2_IO : public JAWS_Asynch_IO
245 public:
246 /// does nothing
247 virtual void accept (JAWS_IO_Handler *ioh,
248 ACE_Message_Block *mb = 0,
249 unsigned int size = 0);
253 typedef ACE_Singleton<JAWS_Asynch2_IO, ACE_SYNCH_MUTEX>
254 JAWS_Asynch2_IO_Singleton;
256 #endif /* ACE_HAS_WIN32_OVERLAPPED_IO || ACE_HAS_AIO_CALLS */
258 #endif /* JAWS_IO_H */