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
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042 #ifndef _VPR_FILE_HANDLE_BRIDGE_H_
00043 #define _VPR_FILE_HANDLE_BRIDGE_H_
00044
00045 #include <vpr/vprConfig.h>
00046
00047 #include <string>
00048 #include <vector>
00049
00050 #include <vpr/IO/BlockIO.h>
00051 #include <vpr/Util/Interval.h>
00052 #include <vpr/Util/ReturnStatus.h>
00053
00054
00055 namespace vpr
00056 {
00057
00062 template<class RealFileHandleImpl>
00063 class FileHandle_t : public BlockIO
00064 {
00065 public:
00076 FileHandle_t(const std::string& file_name)
00077 : BlockIO(file_name), mOpenMode(READ_WRITE), mHandleImpl(file_name)
00078 {
00079 ;
00080 }
00081
00088 virtual ~FileHandle_t()
00089 {
00090 ;
00091 }
00092
00102 virtual const std::string& getName() const
00103 {
00104 return mHandleImpl.getName();
00105 }
00106
00120 virtual vpr::ReturnStatus open()
00121 {
00122 return mHandleImpl.open();
00123 }
00124
00138 virtual vpr::ReturnStatus close()
00139 {
00140 return mHandleImpl.close();
00141 }
00142
00154 virtual vpr::ReturnStatus setBlocking(bool blocking)
00155 {
00156 return mHandleImpl.setBlocking(blocking);
00157 }
00158
00167 bool isBlocking() const
00168 {
00169 return mHandleImpl.isBlocking();
00170 }
00171
00179 virtual IOSys::Handle getHandle() const
00180 {
00181 return mHandleImpl.getHandle();
00182 }
00183
00184
00185
00186
00187
00196 void setOpenReadOnly()
00197 {
00198 mHandleImpl.setOpenReadOnly();
00199 }
00200
00210 void setOpenWriteOnly()
00211 {
00212 mHandleImpl.setOpenWriteOnly();
00213 }
00214
00224 void setOpenReadWrite()
00225 {
00226 mHandleImpl.setOpenReadWrite();
00227 }
00228
00243 vpr::ReturnStatus setAppend(bool flag)
00244 {
00245 return mHandleImpl.setAppend(flag);
00246 }
00247
00263 vpr::ReturnStatus setSynchronousWrite(bool flag)
00264 {
00265 return mHandleImpl.setSynchronousWrite(flag);
00266 }
00267
00278 bool isReadOnly() const
00279 {
00280 return mHandleImpl.isReadOnly();
00281 }
00282
00293 bool isWriteOnly() const
00294 {
00295 return mHandleImpl.isWriteOnly();
00296 }
00297
00308 bool isReadWrite() const
00309 {
00310 return mHandleImpl.isReadWrite();;
00311 }
00312
00313 protected:
00341 vpr::ReturnStatus read_i(void* buffer, const vpr::Uint32 length,
00342 vpr::Uint32& bytes_read,
00343 const vpr::Interval timeout = vpr::Interval::NoTimeout)
00344 {
00345 return mHandleImpl.read_i(buffer, length, bytes_read, timeout);
00346 }
00347
00372 vpr::ReturnStatus readn_i(void* buffer, const vpr::Uint32 length,
00373 vpr::Uint32& bytes_read,
00374 const vpr::Interval timeout = vpr::Interval::NoTimeout)
00375 {
00376 return mHandleImpl.readn_i(buffer, length, bytes_read, timeout);
00377 }
00378
00404 vpr::ReturnStatus write_i(const void* buffer, const vpr::Uint32 length,
00405 vpr::Uint32& bytes_written,
00406 const vpr::Interval timeout = vpr::Interval::NoTimeout)
00407 {
00408 return mHandleImpl.write_i(buffer, length, bytes_written, timeout);
00409 }
00410
00412 RealFileHandleImpl mHandleImpl;
00413 };
00414
00415 }
00416
00417
00418 #endif