3 //=============================================================================
9 //=============================================================================
17 #if !defined (ACE_LACKS_PRAGMA_ONCE)
19 #endif /* ACE_LACKS_PRAGMA_ONCE */
21 #include "ace/Asynch_IO.h"
23 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
24 class ACE_Message_Block
;
25 ACE_END_VERSIONED_NAMESPACE_DECL
27 class JAWS_IO_Handler
;
33 * @brief This class defines the abstract interface for an I/O class in
34 * the context of Web-likes servers
36 * An I/O class should have the following interface. Derived
37 * classes will define the exactly how the I/O will take place
38 * (Asynchronous, Synchronous, Reactive)
45 void handler (JAWS_IO_Handler
*handler
);
47 virtual void handle (ACE_HANDLE h
) = 0;
48 virtual ACE_HANDLE
handle () const = 0;
50 // James, please add documentation here.
52 /// read from the handle size bytes into the message block.
53 virtual void read (ACE_Message_Block
& mb
, int size
) = 0;
55 /// send header, filename, trailer to the handle.
56 virtual void transmit_file (const char *filename
,
60 int trailer_size
) = 0;
62 /// read data from the handle and store in filename.
63 virtual void receive_file (const char *filename
,
65 int initial_data_length
,
66 int entire_length
) = 0;
68 /// send a confirmation message to the handle.
69 virtual void send_confirmation_message (const char *buffer
, int length
) = 0;
71 /// send an error message to the handle.
72 virtual void send_error_message (const char *buffer
, int length
) = 0;
75 JAWS_IO_Handler
*handler_
;
79 * @class JAWS_IO_Handler
81 * @brief This class defines the abstract interface for an I/O handler class in
82 * the context of Web-likes servers
88 virtual ~JAWS_IO_Handler ();
90 /// This method is called by the IO class when new client data shows
92 virtual void read_complete (ACE_Message_Block
&data
) = 0;
94 /// This method is called by the IO class when there was an error in
95 /// reading new data from the client.
96 virtual void read_error () = 0;
98 /// This method is called by the IO class when the requested file has
99 /// been successfully transmitted to the client.
100 virtual void transmit_file_complete () = 0;
102 /// This method is called by the IO class when there was an error in
103 /// transmitting the requested file to the client.
104 virtual void transmit_file_error (int result
) = 0;
106 /// This method is called by the IO class when the requested file has
107 /// been successfully received from the client.
108 virtual void receive_file_complete () = 0;
110 /// This method is called by the IO class when there was an error in
111 /// receiving the requested file from the client.
112 virtual void receive_file_error (int result
) = 0;
114 /// This method is called by the IO class when there was an error in
115 /// writing data to the client.
116 virtual void write_error () = 0;
118 /// This method is called by the IO class when the confirmation
119 /// message has been delivered to the client.
120 virtual void confirmation_message_complete () = 0;
122 /// This method is called by the IO class when the error message has
123 /// been delivered to the client.
124 virtual void error_message_complete () = 0;
128 * @class JAWS_Synch_IO
130 * @brief This class defines the interface for a Synchronous I/O class.
132 class JAWS_Synch_IO
: public JAWS_IO
139 virtual void handle (ACE_HANDLE h
);
140 virtual ACE_HANDLE
handle () const;
142 void read (ACE_Message_Block
& mb
, int size
);
144 void transmit_file (const char *filename
,
150 void receive_file (const char *filename
,
152 int initial_data_length
,
155 void send_confirmation_message (const char *buffer
,
158 void send_error_message (const char *buffer
,
162 virtual void send_message (const char *buffer
,
168 // This only works on Win32
169 #if defined (ACE_HAS_WIN32_OVERLAPPED_IO)
172 * @class JAWS_Asynch_IO
174 * @brief This class defines the interface for a Asynchronous I/O class.
176 class JAWS_Asynch_IO
: public JAWS_IO
, public ACE_Handler
183 virtual void handle (ACE_HANDLE h
) { ACE_Handler::handle (h
); };
184 virtual ACE_HANDLE
handle () const { return ACE_Handler::handle (); };
186 void read (ACE_Message_Block
& mb
, int size
);
188 void transmit_file (const char *filename
,
194 void receive_file (const char *filename
,
196 int initial_data_length
,
199 void send_confirmation_message (const char *buffer
,
202 void send_error_message (const char *buffer
,
212 virtual void send_message (const char *buffer
,
216 /// This method will be called when an asynchronous read completes on
218 virtual void handle_read_stream (const ACE_Asynch_Read_Stream::Result
&result
);
220 /// This method will be called when an asynchronous write completes
222 virtual void handle_write_stream (const ACE_Asynch_Write_Stream::Result
&result
);
224 /// This method will be called when an asynchronous transmit file
226 virtual void handle_transmit_file (const ACE_Asynch_Transmit_File::Result
&result
);
229 #endif /* ACE_HAS_WIN32_OVERLAPPED_IO */
232 //-------------------Adding SYNCH IO no Caching
235 * @class JAWS_Synch_IO_No_Cache
237 * @brief This class defines the interface for a Synchronous I/O class,
238 * however in this class we do not use any caching.
240 * Wondering how this is useful?
241 * The ACE_Filecache ACE_NOMAP option is broken and even if it were not, there
242 * are other use cases in which we want to avoid caching altogether. For example,
243 * we use JAWS in conjunction with the CIAO Repository Manager, however the two
244 * do not have any explicit knowledge of each other. Therefore if the RM tried
245 * to remove a package and its files from disk, its operation would [partially]
246 * fail if JAWS still holds some of the files in its cache.
248 class JAWS_Synch_IO_No_Cache
: public JAWS_IO
251 JAWS_Synch_IO_No_Cache ();
253 ~JAWS_Synch_IO_No_Cache ();
255 virtual void handle (ACE_HANDLE h
);
256 virtual ACE_HANDLE
handle () const;
258 void read (ACE_Message_Block
& mb
, int size
);
260 void transmit_file (const char *filename
,
266 void receive_file (const char *filename
,
268 int initial_data_length
,
271 void send_confirmation_message (const char *buffer
,
274 void send_error_message (const char *buffer
,
278 virtual void send_message (const char *buffer
, int length
);
283 //-------------------
285 #endif /* JAWS_IO_H */