CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch9/src/Utilities/StorageFactory/interface/File.h

Go to the documentation of this file.
00001 #ifndef STORAGE_FACTORY_FILE_H
00002 # define STORAGE_FACTORY_FILE_H
00003 
00004 # include "Utilities/StorageFactory/interface/IOTypes.h"
00005 # include "Utilities/StorageFactory/interface/IOFlags.h"
00006 # include "Utilities/StorageFactory/interface/Storage.h"
00007 # include "Utilities/StorageFactory/interface/IOChannel.h"
00008 # include <string>
00009 
00011 class File : public IOChannel, public Storage
00012 {
00013 public:
00014   File (void);
00015   File (IOFD fd, bool autoclose = true);
00016   File (const char *name, int flags = IOFlags::OpenRead, int perms = 0666);
00017   File (const std::string &name, int flags = IOFlags::OpenRead, int perms = 0666);
00018   ~File (void);
00019   // implicit copy constructor
00020   // implicit assignment operator
00021 
00022   virtual void          create (const char *name,
00023                                 bool exclusive = false,
00024                                 int perms = 0666);
00025   virtual void          create (const std::string &name,
00026                                 bool exclusive = false,
00027                                 int perms = 0666);
00028   virtual void          open (const char *name,
00029                               int flags = IOFlags::OpenRead,
00030                               int perms = 0666);
00031   virtual void          open (const std::string &name,
00032                               int flags = IOFlags::OpenRead,
00033                               int perms = 0666);
00034   virtual void          attach (IOFD fd);
00035 
00036   using Storage::read;
00037   using Storage::write;
00038   using Storage::position;
00039 
00040   virtual bool          prefetch (const IOPosBuffer *what, IOSize n);
00041   virtual IOSize        read (void *into, IOSize n);
00042   virtual IOSize        read (void *into, IOSize n, IOOffset pos);
00043   virtual IOSize        readv (IOBuffer *into, IOSize length);
00044 
00045   virtual IOSize        write (const void *from, IOSize n);
00046   virtual IOSize        write (const void *from, IOSize n, IOOffset pos);
00047   virtual IOSize        writev (const IOBuffer *from, IOSize length);
00048 
00049   virtual IOOffset      size (void) const;
00050   virtual IOOffset      position (IOOffset offset, Relative whence = SET);
00051 
00052   virtual void          resize (IOOffset size);
00053 
00054   virtual void          flush (void);
00055   virtual void          close (void);
00056   virtual void          abort (void);
00057 
00058   virtual void          setAutoClose (bool closeit);
00059 
00060 private:
00061   enum { InternalAutoClose = 4096 }; //< Close on delete
00062 
00063   File (IOFD fd, unsigned flags);
00064 
00065   File *                duplicate (bool copy) const;
00066   File *                duplicate (File *child) const;
00067   static IOFD           sysduplicate (IOFD fd);
00068   static void           sysopen (const char *name, int flags, int perms,
00069                                  IOFD &newfd, unsigned &newflags);
00070   static bool           sysclose (IOFD fd, int *error = 0);
00071 
00072   unsigned              m_flags;
00073 };
00074 
00075 #endif // STORAGE_FACTORY_FILE_H