dmlite  0.4
base.h
Go to the documentation of this file.
1 /// @file include/dmlite/cpp/base.h
2 /// @brief Base interfaces.
3 /// @author Alejandro Álvarez Ayllón <aalvarez@cern.ch>
4 #ifndef DMLITE_CPP_BASE_H
5 #define DMLITE_CPP_BASE_H
6 
7 #include <string>
8 #include "exceptions.h"
9 
10 namespace dmlite {
11 
12  // Forward declarations.
13  class StackInstance;
14  class SecurityContext;
15 
16  /// Base class for interfaces.
17  class BaseInterface {
18  public:
19  /// Virtual destructor
20  virtual ~BaseInterface();
21 
22  /// String ID of the implementation.
23  virtual std::string getImplId(void) const throw() = 0;
24 
25  protected:
26  friend class StackInstance;
27 
28  /// Set the StackInstance.
29  /// Some plugins may need to access other stacks (i.e. the pool may need the catalog)
30  /// However, at construction time not all the stacks have been populated, so this will
31  /// be called once all are instantiated.
32  virtual void setStackInstance(StackInstance* si) throw (DmException) = 0;
33 
34  /// Set the security context.
35  virtual void setSecurityContext(const SecurityContext* ctx) throw (DmException) = 0;
36 
37  /// These method allows plugins to call other plugins setStackInstance and setSecurityContext
38  static void setStackInstance(BaseInterface* i,
39  StackInstance* si) throw (DmException);
40 
41  static void setSecurityContext(BaseInterface* i,
42  const SecurityContext* ctx) throw (DmException);
43  };
44 
45 
46  /// Base class for factories.
47  class BaseFactory {
48  public:
49  /// Virtual destructor
50  virtual ~BaseFactory();
51 
52  /// Set a configuration parameter
53  /// @param key The configuration parameter
54  /// @param value The value for the configuration parameter
55  virtual void configure(const std::string& key, const std::string& value) throw (DmException) = 0;
56  };
57 
58 };
59 
60 #endif // DMLITE_CPP_BASE_H