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