![]() |
![]() |
00001 #ifndef RFIO_ADAPTOR_RFIO_FILE_H 00002 # define RFIO_ADAPTOR_RFIO_FILE_H 00003 00004 # include "Utilities/StorageFactory/interface/Storage.h" 00005 # include "Utilities/StorageFactory/interface/IOChannel.h" 00006 # include "Utilities/StorageFactory/interface/IOFlags.h" 00007 # include <string> 00008 00010 class RFIOFile : public Storage 00011 { 00012 public: 00013 RFIOFile (void); 00014 RFIOFile (IOFD fd); 00015 RFIOFile (const char *name, int flags = IOFlags::OpenRead, int perms = 0666); 00016 RFIOFile (const std::string &name, int flags = IOFlags::OpenRead, int perms = 0666); 00017 ~RFIOFile (void); 00018 00019 virtual void create (const char *name, 00020 bool exclusive = false, 00021 int perms = 0666); 00022 virtual void create (const std::string &name, 00023 bool exclusive = false, 00024 int perms = 0666); 00025 virtual void open (const char *name, 00026 int flags = IOFlags::OpenRead, 00027 int perms = 0666); 00028 virtual void open (const std::string &name, 00029 int flags = IOFlags::OpenRead, 00030 int perms = 0666); 00031 00032 using Storage::read; 00033 using Storage::readv; 00034 using Storage::write; 00035 using Storage::position; 00036 using Storage::prefetch; 00037 00038 virtual bool prefetch (const IOPosBuffer *what, IOSize n); 00039 virtual IOSize read (void *into, IOSize n); 00040 virtual IOSize readv (IOPosBuffer *into, IOSize buffers); 00041 virtual IOSize write (const void *from, IOSize n); 00042 virtual IOOffset position (IOOffset offset, Relative whence = SET); 00043 virtual void resize (IOOffset size); 00044 virtual void close (void); 00045 virtual void abort (void); 00046 00047 private: 00048 ssize_t retryRead (void *into, IOSize n, int maxRetry = 10); 00049 void reopen(); 00050 00051 IOFD m_fd; 00052 bool m_close; 00053 std::string m_name; 00054 int m_flags; 00055 int m_perms; 00056 IOOffset m_curpos; 00057 }; 00058 00059 #endif // RFIO_ADAPTOR_RFIO_FILE_H