dmlite  0.6
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 "dmlite/common/config.h"
8 #include "exceptions.h"
9 #include <string>
10 
11 namespace dmlite {
12 
13  // Forward declarations.
14  class StackInstance;
15  class SecurityContext;
16 
17  /// Base class for interfaces.
18  class BaseInterface {
19  public:
20  /// Virtual destructor
21  virtual ~BaseInterface();
22 
23  /// String ID of the implementation.
24  virtual std::string getImplId(void) const throw() = 0;
25 
26  protected:
27  friend class StackInstance;
28 
29  /// Set the StackInstance.
30  /// Some plugins may need to access other stacks (i.e. the pool may need the catalog)
31  /// However, at construction time not all the stacks have been populated, so this will
32  /// be called once all are instantiated.
33  virtual void setStackInstance(StackInstance* si) throw (DmException);
34 
35  /// Set the security context.
36  virtual void setSecurityContext(const SecurityContext* ctx) throw (DmException);
37 
38  /// These method allows plugins to call other plugins setStackInstance and setSecurityContext
39  static void setStackInstance(BaseInterface* i,
40  StackInstance* si) throw (DmException);
41 
42  static void setSecurityContext(BaseInterface* i,
43  const SecurityContext* ctx) throw (DmException);
44  };
45 
46 
47  /// Base class for factories.
48  class BaseFactory {
49  public:
50  /// Virtual destructor
51  virtual ~BaseFactory();
52 
53  /// Set a configuration parameter
54  /// @param key The configuration parameter
55  /// @param value The value for the configuration parameter
56  virtual void configure(const std::string& key, const std::string& value) throw (DmException);
57  };
58 
59 };
60 
61 #endif // DMLITE_CPP_BASE_H
Base class for interfaces.
Definition: base.h:18
virtual ~BaseFactory()
Virtual destructor.
Definition: dmlite.h:161
virtual void setSecurityContext(const SecurityContext *ctx)
Set the security context.
Security context. To be created by the Authn.
Definition: authn.h:64
Header generated by CMake with the build configuration used.
Base exception class.
Definition: exceptions.h:17
Exceptions used by the API.
Base class for factories.
Definition: base.h:48
virtual void setStackInstance(StackInstance *si)
virtual ~BaseInterface()
Virtual destructor.
virtual void configure(const std::string &key, const std::string &value)
virtual std::string getImplId(void) const =0
String ID of the implementation.