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/IOTypes.h"
00006 # include "Utilities/StorageFactory/interface/IOFlags.h"
00007 # include <string>
00008 # include <map>
00009
00010 class Storage;
00011 class StorageFactory
00012 {
00013 public:
00014 enum CacheHint
00015 {
00016 CACHE_HINT_APPLICATION,
00017 CACHE_HINT_STORAGE,
00018 CACHE_HINT_LAZY_DOWNLOAD,
00019 CACHE_HINT_AUTO_DETECT
00020 };
00021
00022 enum ReadHint
00023 {
00024 READ_HINT_UNBUFFERED,
00025 READ_HINT_READAHEAD,
00026 READ_HINT_AUTO
00027 };
00028
00029 static StorageFactory *get (void);
00030 ~StorageFactory (void);
00031
00032
00033
00034
00035 void setCacheHint(CacheHint value);
00036 CacheHint cacheHint(void) const;
00037
00038 void setReadHint(ReadHint value);
00039 ReadHint readHint(void) const;
00040
00041 bool enableAccounting (bool enabled);
00042 bool accounting (void) const;
00043
00044 void setTempDir (const std::string &s);
00045 std::string tempDir (void) const;
00046
00047 void stagein (const std::string &url);
00048 Storage * open (const std::string &url,
00049 int mode = IOFlags::OpenRead,
00050 const std::string &tmpdir = "");
00051 bool check (const std::string &url,
00052 IOOffset *size = 0);
00053
00054 protected:
00055 typedef std::map<std::string, StorageMaker *> MakerTable;
00056
00057 StorageFactory (void);
00058 StorageMaker *getMaker (const std::string &proto);
00059 StorageMaker *getMaker (const std::string &url,
00060 std::string &protocol,
00061 std::string &rest);
00062
00063 MakerTable m_makers;
00064 CacheHint m_cacheHint;
00065 ReadHint m_readHint;
00066 bool m_accounting;
00067 std::string m_tempdir;
00068 static StorageFactory s_instance;
00069 };
00070
00071 #endif // STORAGE_FACTORY_STORAGE_FACTORY_H