Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-12-24 02:22:25

0001 #ifndef STORAGE_FACTORY_STORAGE_FACTORY_H
0002 #define STORAGE_FACTORY_STORAGE_FACTORY_H
0003 
0004 #include "Utilities/StorageFactory/interface/StorageMaker.h"
0005 #include "Utilities/StorageFactory/interface/LocalFileSystem.h"
0006 #include "Utilities/StorageFactory/interface/IOTypes.h"
0007 #include "Utilities/StorageFactory/interface/IOFlags.h"
0008 #include <string>
0009 #include <memory>
0010 #include "oneapi/tbb/concurrent_unordered_map.h"
0011 
0012 namespace edm::storage {
0013   class Storage;
0014   class StorageFactory {
0015   public:
0016     enum CacheHint { CACHE_HINT_APPLICATION, CACHE_HINT_STORAGE, CACHE_HINT_LAZY_DOWNLOAD, CACHE_HINT_AUTO_DETECT };
0017 
0018     enum ReadHint { READ_HINT_UNBUFFERED, READ_HINT_READAHEAD, READ_HINT_AUTO };
0019 
0020     static const StorageFactory *get(void);
0021     static StorageFactory *getToModify(void);
0022 
0023     ~StorageFactory(void);
0024 
0025     // implicit copy constructor
0026     // implicit assignment operator
0027 
0028     void setCacheHint(CacheHint value);
0029     CacheHint cacheHint(void) const;
0030 
0031     void setReadHint(ReadHint value);
0032     ReadHint readHint(void) const;
0033 
0034     bool enableAccounting(bool enabled);
0035     bool accounting(void) const;
0036 
0037     void setTimeout(unsigned int timeout);
0038     unsigned int timeout(void) const;
0039 
0040     void setDebugLevel(unsigned int level);
0041     unsigned int debugLevel(void) const;
0042 
0043     void setTempDir(const std::string &s, double minFreeSpace);
0044     std::string tempDir(void) const;
0045     std::string tempPath(void) const;
0046     double tempMinFree(void) const;
0047 
0048     void stagein(const std::string &url) const;
0049     std::unique_ptr<Storage> open(const std::string &url, int mode = IOFlags::OpenRead) const;
0050     bool check(const std::string &url, IOOffset *size = nullptr) const;
0051 
0052     std::unique_ptr<Storage> wrapNonLocalFile(std::unique_ptr<Storage> s,
0053                                               const std::string &proto,
0054                                               const std::string &path,
0055                                               int mode) const;
0056 
0057   private:
0058     typedef oneapi::tbb::concurrent_unordered_map<std::string, std::shared_ptr<StorageMaker>> MakerTable;
0059 
0060     StorageFactory(void);
0061     StorageMaker *getMaker(const std::string &proto) const;
0062     StorageMaker *getMaker(const std::string &url, std::string &protocol, std::string &rest) const;
0063 
0064     mutable MakerTable m_makers;
0065     CacheHint m_cacheHint;
0066     ReadHint m_readHint;
0067     bool m_accounting;
0068     double m_tempfree;
0069     std::string m_temppath;
0070     std::string m_tempdir;
0071     std::string m_unusableDirWarnings;
0072     unsigned int m_timeout;
0073     unsigned int m_debugLevel;
0074     LocalFileSystem m_lfs;
0075     static StorageFactory s_instance;
0076   };
0077 }  // namespace edm::storage
0078 #endif  // STORAGE_FACTORY_STORAGE_FACTORY_H