~ubuntu-branches/ubuntu/breezy/ace/breezy

« back to all changes in this revision

Viewing changes to apps/JAWS/server/IO.h

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad, Benjamin Montgomery, Adam Conrad
  • Date: 2005-09-18 22:51:38 UTC
  • mfrom: (1.2.1 upstream) (2.1.1 sarge) (0.1.2 woody)
  • Revision ID: james.westby@ubuntu.com-20050918225138-seav22q6fyylb536
Tags: 5.4.7-3ubuntu1
[ Benjamin Montgomery ]
* Added a patch for amd64 and powerpc that disables the compiler
  option -fvisibility-inlines-hidden

[ Adam Conrad ]
* Added DPATCH_OPTION_CPP=1 to debian/patches/00options to make
  Benjamin's above changes work correctly with dpatch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* -*- c++ -*- */
2
 
// Hey, Emacs!  This is a C++ file!
3
 
// IO.h,v 1.10 2001/02/18 15:35:28 schmidt Exp
4
 
 
5
 
// ============================================================================
6
 
//
7
 
// = LIBRARY
8
 
//   jaws
9
 
//
10
 
// = FILENAME
11
 
//    IO.h
12
 
//
13
 
// = AUTHOR
14
 
//    James Hu
15
 
//
16
 
// ============================================================================
17
 
 
18
 
#ifndef JAWS_IO_H
19
 
#define JAWS_IO_H
20
 
 
21
 
class ACE_Message_Block;
22
 
class JAWS_IO_Handler;
23
 
 
24
 
#include "ace/ACE.h"
25
 
 
26
 
#if !defined (ACE_LACKS_PRAGMA_ONCE)
27
 
# pragma once
28
 
#endif /* ACE_LACKS_PRAGMA_ONCE */
29
 
 
30
 
#include "ace/Asynch_IO.h"
31
 
 
32
 
class JAWS_IO
33
 
  // = TITLE
34
 
  //
35
 
  //     This class defines the abstract interface for an I/O class in
36
 
  //     the context of Web-likes servers
37
 
  //
38
 
  // = DESCRIPTION
39
 
  //
40
 
  //     An I/O class should have the following interface. Derived
41
 
  //     classes will define the exactly how the I/O will take place
42
 
  //     (Asynchronous, Synchronous, Reactive)
43
 
{
44
 
public:
45
 
  JAWS_IO (void);
46
 
  virtual ~JAWS_IO (void);
47
 
  void handler (JAWS_IO_Handler *handler);
48
 
 
49
 
  virtual void handle (ACE_HANDLE h) = 0;
50
 
  virtual ACE_HANDLE handle (void) const = 0;
51
 
 
52
 
  // James, please add documentation here.
53
 
 
54
 
  virtual void read (ACE_Message_Block& mb, int size) = 0;
55
 
  // read from the handle size bytes into the message block.
56
 
 
57
 
  virtual void transmit_file (const char *filename,
58
 
                              const char *header,
59
 
                              int header_size,
60
 
                              const char *trailer,
61
 
                              int trailer_size) = 0;
62
 
  // send header, filename, trailer to the handle.
63
 
 
64
 
  virtual void receive_file (const char *filename,
65
 
                             void *initial_data,
66
 
                             int initial_data_length,
67
 
                             int entire_length) = 0;
68
 
  // read data from the handle and store in filename.
69
 
 
70
 
  virtual void send_confirmation_message (const char *buffer, int length) = 0;
71
 
  // send a confirmation message to the handle.
72
 
 
73
 
  virtual void send_error_message (const char *buffer, int length) = 0;
74
 
  // send an error message to the handle.
75
 
 
76
 
protected:
77
 
  JAWS_IO_Handler *handler_;
78
 
};
79
 
 
80
 
class JAWS_IO_Handler
81
 
  // = TITLE
82
 
  //
83
 
  //     This class defines the abstract interface for an I/O handler class in
84
 
  //     the context of Web-likes servers
85
 
  //
86
 
  // = DESCRIPTION
87
 
{
88
 
public:
89
 
  virtual void read_complete (ACE_Message_Block &data) = 0;
90
 
  // This method is called by the IO class when new client data shows
91
 
  // up.
92
 
 
93
 
  virtual void read_error (void) = 0;
94
 
  // This method is called by the IO class when there was an error in
95
 
  // reading new data from the client.
96
 
 
97
 
  virtual void transmit_file_complete (void) = 0;
98
 
  // This method is called by the IO class when the requested file has
99
 
  // been successfully transmitted to the client.
100
 
 
101
 
  virtual void transmit_file_error (int result) = 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
 
 
105
 
  virtual void receive_file_complete (void) = 0;
106
 
  // This method is called by the IO class when the requested file has
107
 
  // been successfully received from the client.
108
 
 
109
 
  virtual void receive_file_error (int result) = 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
 
 
113
 
  virtual void write_error (void) = 0;
114
 
  // This method is called by the IO class when there was an error in
115
 
  // writing data to the client.
116
 
 
117
 
  virtual void confirmation_message_complete (void) = 0;
118
 
  // This method is called by the IO class when the confirmation
119
 
  // message has been delivered to the client.
120
 
 
121
 
  virtual void error_message_complete (void) = 0;
122
 
  // This method is called by the IO class when the error message has
123
 
  // been delivered to the client.
124
 
 
125
 
};
126
 
 
127
 
class JAWS_Synch_IO : public JAWS_IO
128
 
  // = TITLE
129
 
  //
130
 
  //     This class defines the interface for a Synchronous I/O class.
131
 
  //
132
 
  // = DESCRIPTION
133
 
{
134
 
public:
135
 
  JAWS_Synch_IO (void);
136
 
 
137
 
  ~JAWS_Synch_IO (void);
138
 
 
139
 
  virtual void handle (ACE_HANDLE h);
140
 
  virtual ACE_HANDLE handle (void) const;
141
 
 
142
 
  void read (ACE_Message_Block& mb, int size);
143
 
 
144
 
  void transmit_file (const char *filename,
145
 
                      const char *header,
146
 
                      int header_size,
147
 
                      const char *trailer,
148
 
                      int trailer_size);
149
 
 
150
 
  void receive_file (const char *filename,
151
 
                     void *initial_data,
152
 
                     int initial_data_length,
153
 
                     int entire_length);
154
 
 
155
 
  void send_confirmation_message (const char *buffer,
156
 
                                  int length);
157
 
 
158
 
  void send_error_message (const char *buffer,
159
 
                           int length);
160
 
 
161
 
protected:
162
 
  virtual void send_message (const char *buffer,
163
 
                             int length);
164
 
 
165
 
  ACE_HANDLE handle_;
166
 
};
167
 
 
168
 
// This only works on Win32
169
 
#if defined (ACE_WIN32)
170
 
 
171
 
class JAWS_Asynch_IO : public JAWS_IO, public ACE_Handler
172
 
  // = TITLE
173
 
  //
174
 
  //     This class defines the interface for a Asynchronous I/O class.
175
 
  //
176
 
  // = DESCRIPTION
177
 
{
178
 
public:
179
 
  JAWS_Asynch_IO (void);
180
 
 
181
 
  ~JAWS_Asynch_IO (void);
182
 
 
183
 
  virtual void handle (ACE_HANDLE h) { ACE_Handler::handle (h); };
184
 
  virtual ACE_HANDLE handle (void) const { return ACE_Handler::handle (); };
185
 
 
186
 
  void read (ACE_Message_Block& mb, int size);
187
 
 
188
 
  void transmit_file (const char *filename,
189
 
                      const char *header,
190
 
                      int header_size,
191
 
                      const char *trailer,
192
 
                      int trailer_size);
193
 
 
194
 
  void receive_file (const char *filename,
195
 
                     void *initial_data,
196
 
                     int initial_data_length,
197
 
                     int entire_length);
198
 
 
199
 
  void send_confirmation_message (const char *buffer,
200
 
                                  int length);
201
 
 
202
 
  void send_error_message (const char *buffer,
203
 
                           int length);
204
 
 
205
 
protected:
206
 
  enum Message_Types
207
 
  {
208
 
    CONFORMATION,
209
 
    ERROR_MESSAGE
210
 
  };
211
 
 
212
 
  virtual void send_message (const char *buffer,
213
 
                             int length,
214
 
                             int act);
215
 
 
216
 
  virtual void handle_read_stream (const ACE_Asynch_Read_Stream::Result &result);
217
 
  // This method will be called when an asynchronous read completes on
218
 
  // a stream.
219
 
 
220
 
  virtual void handle_write_stream (const ACE_Asynch_Write_Stream::Result &result);
221
 
  // This method will be called when an asynchronous write completes
222
 
  // on a stream.
223
 
 
224
 
  virtual void handle_transmit_file (const ACE_Asynch_Transmit_File::Result &result);
225
 
  // This method will be called when an asynchronous transmit file
226
 
  // completes.
227
 
};
228
 
 
229
 
#endif /* ACE_WIN32 */
230
 
#endif /* JAWS_IO_H */
231