dmlite
0.6
|
00001 /// @file include/dmlite/cpp/poolmanager.h 00002 /// @brief Pool API. 00003 /// @author Alejandro Álvarez Ayllón <aalvarez@cern.ch> 00004 #ifndef DMLITE_CPP_POOLMANAGER_H 00005 #define DMLITE_CPP_POOLMANAGER_H 00006 00007 #include "../common/config.h" 00008 #include "base.h" 00009 #include "exceptions.h" 00010 #include "pooldriver.h" 00011 #include "utils/extensible.h" 00012 00013 #include <string> 00014 #include <vector> 00015 00016 namespace dmlite { 00017 00018 // Forward declarations. 00019 class StackInstance; 00020 00021 /// Internal interface for handling pool metadata. 00022 struct Pool: public Extensible { 00023 std::string name; 00024 std::string type; 00025 00026 bool operator == (const Pool&) const; 00027 bool operator != (const Pool&) const; 00028 bool operator < (const Pool&) const; 00029 bool operator > (const Pool&) const; 00030 }; 00031 00032 /// Interface for pool types. 00033 class PoolManager: public virtual BaseInterface { 00034 public: 00035 enum PoolAvailability { kAny, kNone, kForRead, kForWrite, kForBoth}; 00036 00037 /// Destructor. 00038 virtual ~PoolManager(); 00039 00040 /// Get the list of pools. 00041 /// @param availability Filter by availability. 00042 virtual std::vector<Pool> getPools(PoolAvailability availability = kAny) throw (DmException); 00043 00044 /// Get a specific pool. 00045 virtual Pool getPool(const std::string& poolname) throw (DmException); 00046 00047 /// Create a new pool. 00048 virtual void newPool(const Pool& pool) throw (DmException); 00049 00050 /// Update pool metadata. 00051 virtual void updatePool(const Pool& pool) throw (DmException); 00052 00053 /// Remove a pool. 00054 virtual void deletePool(const Pool& pool) throw (DmException); 00055 00056 /// Get a location for a logical name. 00057 /// @param path The path to get. 00058 virtual Location whereToRead(const std::string& path) throw (DmException); 00059 00060 /// Get a location for an inode 00061 /// @param inode The file inode. 00062 virtual Location whereToRead(ino_t inode) throw (DmException); 00063 00064 /// Start the PUT of a file. 00065 /// @param path The path of the file to create. 00066 /// @return The physical location where to write. 00067 virtual Location whereToWrite(const std::string& path) throw (DmException); 00068 00069 /// Cancel a write. 00070 /// @param path The logical file name. 00071 /// @param loc As returned by whereToWrite 00072 virtual void cancelWrite(const Location& loc) throw (DmException); 00073 }; 00074 00075 /// Plug-ins must implement a concrete factory to be instantiated. 00076 class PoolManagerFactory: public virtual BaseFactory { 00077 public: 00078 /// Virtual destructor 00079 virtual ~PoolManagerFactory(); 00080 00081 protected: 00082 // Stack instance is allowed to instantiate PoolManager 00083 friend class StackInstance; 00084 00085 /// Children of PoolManagerFactory are allowed to instantiate too (decorator) 00086 static PoolManager* createPoolManager(PoolManagerFactory* factory, 00087 PluginManager* pm) throw (DmException); 00088 00089 /// Instantiate a implementation of Pool 00090 virtual PoolManager* createPoolManager(PluginManager* pm) throw (DmException); 00091 }; 00092 00093 }; 00094 00095 #endif // DMLITE_CPP_POOLMANAGER_H