CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/Utilities/StorageFactory/interface/StorageFactory.h

Go to the documentation of this file.
00001 #ifndef STORAGE_FACTORY_STORAGE_FACTORY_H
00002 # define STORAGE_FACTORY_STORAGE_FACTORY_H
00003 
00004 # include "Utilities/StorageFactory/interface/StorageMaker.h"
00005 # include "Utilities/StorageFactory/interface/LocalFileSystem.h"
00006 # include "Utilities/StorageFactory/interface/IOTypes.h"
00007 # include "Utilities/StorageFactory/interface/IOFlags.h"
00008 # include <string>
00009 # include <map>
00010 
00011 class Storage;
00012 class StorageFactory 
00013 {
00014 public:
00015   enum CacheHint
00016   {
00017     CACHE_HINT_APPLICATION,
00018     CACHE_HINT_STORAGE,
00019     CACHE_HINT_LAZY_DOWNLOAD,
00020     CACHE_HINT_AUTO_DETECT
00021   };
00022 
00023   enum ReadHint
00024   {
00025     READ_HINT_UNBUFFERED,
00026     READ_HINT_READAHEAD,
00027     READ_HINT_AUTO
00028   };
00029 
00030   static StorageFactory *get (void);
00031   ~StorageFactory (void);
00032 
00033   // implicit copy constructor
00034   // implicit assignment operator
00035 
00036   void          setCacheHint(CacheHint value);
00037   CacheHint     cacheHint(void) const;
00038 
00039   void          setReadHint(ReadHint value);
00040   ReadHint      readHint(void) const;
00041 
00042   bool          enableAccounting (bool enabled);
00043   bool          accounting (void) const;
00044 
00045   void          setTimeout(unsigned int timeout);
00046   unsigned int  timeout(void) const;
00047 
00048   void          setTempDir (const std::string &s, double minFreeSpace);
00049   std::string   tempDir (void) const;
00050   std::string   tempPath (void) const;
00051   double        tempMinFree (void) const;
00052 
00053   void          stagein (const std::string &url);
00054   Storage *     open (const std::string &url,
00055                       int mode = IOFlags::OpenRead);
00056   bool          check (const std::string &url,
00057                        IOOffset *size = 0);
00058   void          activateTimeout (const std::string &url);
00059 
00060   Storage *     wrapNonLocalFile (Storage *s,
00061                                   const std::string &proto,
00062                                   const std::string &path,
00063                                   int mode);
00064 
00065 protected:
00066   typedef std::map<std::string, StorageMaker *> MakerTable;
00067 
00068   StorageFactory (void);
00069   StorageMaker *getMaker (const std::string &proto);
00070   StorageMaker *getMaker (const std::string &url,
00071                           std::string &protocol,
00072                           std::string &rest);
00073   
00074   MakerTable    m_makers;
00075   CacheHint     m_cacheHint;
00076   ReadHint      m_readHint;
00077   bool          m_accounting;
00078   double        m_tempfree;
00079   std::string   m_temppath;
00080   std::string   m_tempdir;
00081   unsigned int  m_timeout;
00082   LocalFileSystem m_lfs;
00083   static StorageFactory s_instance;
00084 };
00085 
00086 #endif // STORAGE_FACTORY_STORAGE_FACTORY_H