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
00028
00029 #ifndef FILE_SINK_H
00030 #define FILE_SINK_H
00031
00032 #ifndef __cplusplus
00033 #error This is a C++ include file
00034 #endif
00035
00036
00037
00038
00039 #include "Reporter.h"
00040 #include "Sink.h"
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00057 class FileSink : public Sink, public virtual Reporter
00058 {
00059 private:
00060
00064 char * fileName;
00065
00072 void
00073 init ( const char * name ) throw ( Exception );
00074
00080 void
00081 strip ( void ) throw ( Exception );
00082
00083
00084 protected:
00085
00089 int fileDescriptor;
00090
00096 inline
00097 FileSink ( void ) throw ( Exception )
00098 {
00099 throw Exception( __FILE__, __LINE__);
00100 }
00101
00102
00103 public:
00104
00111 inline
00112 FileSink( const char * name ) throw ( Exception )
00113 {
00114 init( name);
00115 }
00116
00123 FileSink( const FileSink & fsink ) throw ( Exception );
00124
00130 inline virtual
00131 ~FileSink( void ) throw ( Exception )
00132 {
00133 strip();
00134 }
00135
00143 virtual FileSink &
00144 operator= ( const FileSink & fs ) throw ( Exception );
00145
00151 inline const char *
00152 getFileName ( void ) const throw ()
00153 {
00154 return fileName;
00155 }
00156
00163 virtual bool
00164 exists ( void ) const throw ();
00165
00172 virtual bool
00173 create ( void ) throw ( Exception );
00174
00181 virtual bool
00182 open ( void ) throw ( Exception );
00183
00189 inline virtual bool
00190 isOpen ( void ) const throw ()
00191 {
00192 return fileDescriptor != 0;
00193 }
00194
00204 virtual bool
00205 canWrite ( unsigned int sec,
00206 unsigned int usec ) throw ( Exception );
00207
00216 virtual unsigned int
00217 write ( const void * buf,
00218 unsigned int len ) throw ( Exception );
00219
00225 inline virtual void
00226 flush ( void ) throw ( Exception )
00227 {
00228 }
00229
00235 virtual void
00236 close ( void ) throw ( Exception );
00237 };
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247 #endif
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269