dmlite  0.6
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 "dmlite/common/config.h"
8 #include "base.h"
9 #include "exceptions.h"
10 #include "pooldriver.h"
11 #include "utils/extensible.h"
12 
13 #include <string>
14 #include <vector>
15 
16 namespace dmlite {
17 
18  // Forward declarations.
19  class StackInstance;
20 
21  /// Internal interface for handling pool metadata.
22  struct Pool: public Extensible {
23  std::string name;
24  std::string type;
25 
26  bool operator == (const Pool&) const;
27  bool operator != (const Pool&) const;
28  bool operator < (const Pool&) const;
29  bool operator > (const Pool&) const;
30  };
31 
32  /// Interface for pool types.
33  class PoolManager: public virtual BaseInterface {
34  public:
36 
37  /// Destructor.
38  virtual ~PoolManager();
39 
40  /// Get the list of pools.
41  /// @param availability Filter by availability.
42  virtual std::vector<Pool> getPools(PoolAvailability availability = kAny) throw (DmException);
43 
44  /// Get a specific pool.
45  virtual Pool getPool(const std::string& poolname) throw (DmException);
46 
47  /// Create a new pool.
48  virtual void newPool(const Pool& pool) throw (DmException);
49 
50  /// Update pool metadata.
51  virtual void updatePool(const Pool& pool) throw (DmException);
52 
53  /// Remove a pool.
54  virtual void deletePool(const Pool& pool) throw (DmException);
55 
56  /// Get a location for a logical name.
57  /// @param path The path to get.
58  virtual Location whereToRead(const std::string& path) throw (DmException);
59 
60  /// Get a location for an inode
61  /// @param inode The file inode.
62  virtual Location whereToRead(ino_t inode) throw (DmException);
63 
64  /// Start the PUT of a file.
65  /// @param path The path of the file to create.
66  /// @return The physical location where to write.
67  virtual Location whereToWrite(const std::string& path) throw (DmException);
68 
69  /// Cancel a write.
70  /// @param path The logical file name.
71  /// @param loc As returned by whereToWrite
72  virtual void cancelWrite(const Location& loc) throw (DmException);
73  };
74 
75  /// Plug-ins must implement a concrete factory to be instantiated.
76  class PoolManagerFactory: public virtual BaseFactory {
77  public:
78  /// Virtual destructor
79  virtual ~PoolManagerFactory();
80 
81  protected:
82  // Stack instance is allowed to instantiate PoolManager
83  friend class StackInstance;
84 
85  /// Children of PoolManagerFactory are allowed to instantiate too (decorator)
86  static PoolManager* createPoolManager(PoolManagerFactory* factory,
87  PluginManager* pm) throw (DmException);
88 
89  /// Instantiate a implementation of Pool
90  virtual PoolManager* createPoolManager(PluginManager* pm) throw (DmException);
91  };
92 
93 };
94 
95 #endif // DMLITE_CPP_POOLMANAGER_H
virtual Location whereToRead(const std::string &path)
virtual void newPool(const Pool &pool)
Create a new pool.
std::string type
Definition: poolmanager.h:24
Base class for interfaces.
Definition: base.h:18
Plug-ins must implement a concrete factory to be instantiated.
Definition: poolmanager.h:76
Definition: dmlite.h:161
PoolAvailability
Definition: poolmanager.h:35
Definition: poolmanager.h:35
Header generated by CMake with the build configuration used.
Represent the complete location of a file.
Definition: pooldriver.h:42
Base exception class.
Definition: exceptions.h:17
CatalogInterface can only be instantiated through this class.
Definition: dmlite.h:42
Interface for pool types.
Definition: poolmanager.h:33
bool operator==(const Pool &) const
virtual std::vector< Pool > getPools(PoolAvailability availability=kAny)
Exceptions used by the API.
bool operator>(const Pool &) const
Helpful typedef for KeyValue containers.
Definition: extensible.h:20
bool operator!=(const Pool &) const
Base class for factories.
Definition: base.h:48
virtual ~PoolManager()
Destructor.
virtual void updatePool(const Pool &pool)
Update pool metadata.
std::string name
Definition: poolmanager.h:23
Extensible types (hold metadata).
Internal interface for handling pool metadata.
Definition: poolmanager.h:22
Definition: poolmanager.h:35
Base interfaces.
virtual void deletePool(const Pool &pool)
Remove a pool.
virtual Location whereToWrite(const std::string &path)
Definition: poolmanager.h:35
Definition: poolmanager.h:35
virtual void cancelWrite(const Location &loc)
Definition: poolmanager.h:35
bool operator<(const Pool &) const
virtual Pool getPool(const std::string &poolname)
Get a specific pool.
Pool handling API.