dmlite  0.4
poolmanager.h
Go to the documentation of this file.
1 /// @file include/dmlite/cpp/poolmanager.h
2 /// @brief Pool API.
3 /// @author Alejandro Álvarez Ayllón <aalvarez@cern.ch>
4 #ifndef DMLITE_CPP_POOLMANAGER_H
5 #define DMLITE_CPP_POOLMANAGER_H
6 
7 #include <string>
8 #include <vector>
9 #include "base.h"
10 #include "exceptions.h"
11 #include "pooldriver.h"
12 #include "utils/extensible.h"
13 
14 namespace dmlite {
15 
16  // Forward declarations.
17  class StackInstance;
18 
19  /// Internal interface for handling pool metadata.
20  struct Pool: public Extensible {
21  std::string name;
22  std::string type;
23 
24  bool operator == (const Pool&) const;
25  bool operator != (const Pool&) const;
26  bool operator < (const Pool&) const;
27  bool operator > (const Pool&) const;
28  };
29 
30  /// Interface for pool types.
31  class PoolManager: public virtual BaseInterface {
32  public:
34 
35  /// Destructor.
36  virtual ~PoolManager();
37 
38  /// Get the list of pools.
39  /// @param availability Filter by availability.
40  virtual std::vector<Pool> getPools(PoolAvailability availability = kAny) throw (DmException) = 0;
41 
42  /// Get a specific pool.
43  virtual Pool getPool(const std::string& poolname) throw (DmException) = 0;
44 
45  /// Create a new pool.
46  virtual void newPool(const Pool& pool) throw (DmException) = 0;
47 
48  /// Update pool metadata.
49  virtual void updatePool(const Pool& pool) throw (DmException) = 0;
50 
51  /// Remove a pool.
52  virtual void deletePool(const Pool& pool) throw (DmException) = 0;
53 
54  /// Get a location for a logical name.
55  /// @param path The path to get.
56  virtual Location whereToRead(const std::string& path) throw (DmException) = 0;
57 
58  /// Get a location for an inode
59  /// @param inode The file inode.
60  virtual Location whereToRead(ino_t inode) throw (DmException) = 0;
61 
62  /// Start the PUT of a file.
63  /// @param path The path of the file to create.
64  /// @return The physical location where to write.
65  virtual Location whereToWrite(const std::string& path) throw (DmException) = 0;
66  };
67 
68  /// Plug-ins must implement a concrete factory to be instantiated.
69  class PoolManagerFactory: public virtual BaseFactory {
70  public:
71  /// Virtual destructor
72  virtual ~PoolManagerFactory();
73 
74  protected:
75  // Stack instance is allowed to instantiate PoolManager
76  friend class StackInstance;
77 
78  /// Children of PoolManagerFactory are allowed to instantiate too (decorator)
79  static PoolManager* createPoolManager(PoolManagerFactory* factory,
80  PluginManager* pm) throw (DmException);
81 
82  /// Instantiate a implementation of Pool
83  virtual PoolManager* createPoolManager(PluginManager* pm) throw (DmException) = 0;
84  };
85 
86 };
87 
88 #endif // DMLITE_CPP_POOLMANAGER_H