CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_10/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          setDebugLevel(unsigned int level);
00049   unsigned int  debugLevel(void) const;
00050 
00051   void          setTempDir (const std::string &s, double minFreeSpace);
00052   std::string   tempDir (void) const;
00053   std::string   tempPath (void) const;
00054   double        tempMinFree (void) const;
00055 
00056   void          stagein (const std::string &url);
00057   Storage *     open (const std::string &url,
00058                       int mode = IOFlags::OpenRead);
00059   bool          check (const std::string &url,
00060                        IOOffset *size = 0);
00061   void          activateTimeout (const std::string &url);
00062 
00063   Storage *     wrapNonLocalFile (Storage *s,
00064                                   const std::string &proto,
00065                                   const std::string &path,
00066                                   int mode);
00067 
00068 protected:
00069   typedef std::map<std::string, StorageMaker *> MakerTable;
00070 
00071   StorageFactory (void);
00072   StorageMaker *getMaker (const std::string &proto);
00073   StorageMaker *getMaker (const std::string &url,
00074                           std::string &protocol,
00075                           std::string &rest);
00076   
00077   MakerTable    m_makers;
00078   CacheHint     m_cacheHint;
00079   ReadHint      m_readHint;
00080   bool          m_accounting;
00081   double        m_tempfree;
00082   std::string   m_temppath;
00083   std::string   m_tempdir;
00084   unsigned int  m_timeout;
00085   unsigned int  m_debugLevel;
00086   LocalFileSystem m_lfs;
00087   static StorageFactory s_instance;
00088 };
00089 
00090 #endif // STORAGE_FACTORY_STORAGE_FACTORY_H