00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #ifndef CEYLAN_PIPE_H_
00028 #define CEYLAN_PIPE_H_
00029
00030
00031 #include "CeylanInputOutputStream.h"
00032 #include "CeylanFeatures.h"
00033
00034
00035
00036 namespace Ceylan
00037 {
00038
00039
00040 namespace System
00041 {
00042
00043
00044
00055 class CEYLAN_DLL Pipe: public InputOutputStream
00056 {
00057
00058
00059 public:
00060
00061
00062
00064 class PipeException: public SystemException
00065 {
00066 public:
00067
00068 explicit PipeException( const std::string & reason ) ;
00069
00070 virtual ~PipeException() throw() ;
00071
00072 } ;
00073
00074
00075
00076 class CouldNotCreate: public PipeException
00077 {
00078 public:
00079
00080 explicit CouldNotCreate( const std::string & reason ) ;
00081
00082 } ;
00083
00084
00085
00086 class ReadFailed: public InputStream::ReadFailedException
00087 {
00088 public:
00089
00090 explicit ReadFailed( const std::string & reason ) ;
00091
00092 } ;
00093
00094
00095
00096 class WriteFailed: public OutputStream::WriteFailedException
00097 {
00098 public:
00099
00100 explicit WriteFailed( const std::string & reason ) ;
00101
00102 } ;
00103
00104
00105
00106
00114 Pipe() ;
00115
00116
00126 explicit Pipe( const Pipe & other ) ;
00127
00128
00130 virtual ~Pipe() throw() ;
00131
00132
00133
00150 virtual Size read( char * buffer, Size maxLength ) ;
00151
00152
00153
00165 virtual Size write( const std::string & message ) ;
00166
00167
00168
00183 virtual Size write( const char * buffer, Size maxLength ) ;
00184
00185
00186
00191 virtual bool hasAvailableData() const ;
00192
00193
00194
00196 virtual void clearInput() ;
00197
00198
00199
00208 virtual bool close() ;
00209
00210
00212 virtual StreamID getInputStreamID() const ;
00213
00214
00216 virtual StreamID getOutputStreamID() const ;
00217
00218
00219
00220
00221 protected:
00222
00223
00225 FileDescriptor getReadFileDescriptor() const ;
00226
00227
00229 FileDescriptor getWriteFileDescriptor() const ;
00230
00231
00232
00233 private:
00234
00235
00236
00254 Pipe & operator = ( const Pipe & source ) ;
00255
00256
00257
00262 mutable FileDescriptor _fd[ 2 ] ;
00263
00264
00265 } ;
00266
00267
00268 }
00269
00270 }
00271
00272
00273
00274 #endif // CEYLAN_PIPE_H_
00275