All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
IInspector.h
Go to the documentation of this file.
1 // $Header: /tmp/svngaudi/tmp.jEpFh25751/Gaudi/GaudiKernel/GaudiKernel/IInspector.h,v 1.4 2006/11/30 15:22:07 dquarrie Exp $
2 #ifndef GAUDIKERNEL_IINSPECTOR_H
3 #define GAUDIKERNEL_IINSPECTOR_H
4 
5 // STL Include files
6 #include <typeinfo>
7 #include <string>
8 
9 // Framework Include files
10 #include "GaudiKernel/IInterface.h"
11 
16 class GAUDI_API IInspector: virtual public IInterface {
17 public:
20 
21  enum { MUTABLE = 1<<1, CONST = 1<<2};
22 
23 protected:
24 
27  class IValue {
28  protected:
29  void* m_P;
30  IValue() { }
31  public:
32  virtual ~IValue() { }
33  virtual void release() { delete this; }
34  void* ptr() { return m_P; }
35  const void* ptr() const { return m_P; }
36  virtual long size() const = 0;
37  virtual void construct(void* buffer) const = 0;
38  };
39 
42  class Tag {
43  public:
44  long first;
45  const std::type_info& second;
46  Tag(long f, const std::type_info& s) : first(f), second(s) { }
47  Tag(const Tag& t) : first(t.first), second(t.second) { }
48  };
49 
50 private:
53  template <class T> class _V : public IValue {
54  T m_O;
55  public:
56  _V(const T& v) : m_O(v) { m_P = &m_O; }
57  virtual ~_V() { }
58  virtual long size() const { return sizeof(T); }
59  void construct(void* b) const { ::new(b) T(); }
60  };
61 
64  template <class T> class _TT : public Tag {
65  public: _TT() : Tag(sizeof(T), typeid(T)) { }
66  };
67 
68 protected:
69  // Referenced implementation of the IInspector interface:
71  virtual StatusCode inspectByRef(const void* pObj, const Tag& typ, void* pOwner, const Tag& otag, const std::string& comment, long flag) = 0;
73  virtual StatusCode inspectByValue(IValue* pObj, const Tag& typ, void* pOwner, const Tag& oTag, const std::string& comment) = 0;
75  virtual StatusCode inspectContByRef(const void* pObj, const Tag& tag, const Tag& rtag, const Tag& vtag, const void* pOwner, const Tag& otag, const std::string& comment, long flags) = 0;
77  virtual StatusCode inspectContByValue(IValue* pObj, const Tag& tag, const Tag& rtag, const Tag& vtag, const void* pOwner, const Tag& otag, const std::string& comment) = 0;
78 
79 public:
80  // User interface of the IInspector interface
82  template < class T, class O >
83  StatusCode inspectByRef(const T* pObj, const O* pOwner, const std::string& comment, long flag=MUTABLE) {
84  return inspectByRef(pObj, _TT<T>(), (void*)pOwner, _TT<O>(), comment, flag);
85  }
87  template < class T, class O >
88  StatusCode inspectByValue(const T& obj, const O* pOwner, const std::string& comment) {
89  return inspectByValue(new _V<T>(obj), _TT<T>(), (void*)pOwner, _TT<O>(), comment);
90  }
92  template < class T, class O >
93  StatusCode inspectContByRef( const T* pObj, const O* pOwner, const std::string& comment, long flag=MUTABLE) {
94  typedef typename T::value_type _VVV;
95  typedef typename T::value_type _TTT;
96  // Unfortunately this is not implemented on G++:
97  // typedef typename T::allocator_type::value_type _TTT;
98  return inspectContByRef((void*)pObj, _TT<T>(), _TT<_VVV>(), _TT<_TTT>(), (void*)pOwner, _TT<O>(), comment, flag);
99  }
101  template < class T, class O >
102  StatusCode inspectContByValue( const T& obj, const O* pOwner, const std::string& comment) {
103  typedef typename T::value_type _VVV;
104  typedef typename T::value_type _TTT;
105  // Unfortunately this is not implemented on G++:
106  // typedef typename T::allocator_type::value_type _TTT;
107  return inspectContByValue(new _V<T>(obj), _TT<T>(), _TT<_VVV>(), _TT<_TTT>(), (void*)pOwner, _TT<O>(), comment);
108  }
109 };
110 #endif // GAUDIKERNEL_IINSPECTOR_H
StatusCode inspectByRef(const T *pObj, const O *pOwner, const std::string &comment, long flag=MUTABLE)
Inspect single item by its reference (mutable and const)
Definition: IInspector.h:83
StatusCode inspectByValue(const T &obj, const O *pOwner, const std::string &comment)
Inspect single item by its value (const)
Definition: IInspector.h:88
Tag(const Tag &t)
Definition: IInspector.h:47
Tag(long f, const std::type_info &s)
Definition: IInspector.h:46
virtual void release()
Definition: IInspector.h:33
_V(const T &v)
Definition: IInspector.h:56
StatusCode inspectContByValue(const T &obj, const O *pOwner, const std::string &comment)
Inspect container of object items by its value (const)
Definition: IInspector.h:102
virtual ~_V()
Definition: IInspector.h:57
Inspector base class.
Definition: IInspector.h:16
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:30
Definition of the basic interface.
Definition: IInterface.h:160
#define DeclareInterfaceID(name, major, minor)
Macro to declare the interface ID when using the new mechanism of extending and implementing interfac...
Definition: IInterface.h:23
StatusCode inspectContByRef(const T *pObj, const O *pOwner, const std::string &comment, long flag=MUTABLE)
Inspect container of object items by its reference (mutable and const)
Definition: IInspector.h:93
virtual ~IValue()
Definition: IInspector.h:32
const void * ptr() const
Definition: IInspector.h:35
string s
Definition: gaudirun.py:210
const std::type_info & second
Definition: IInspector.h:45
virtual long size() const
Definition: IInspector.h:58
#define GAUDI_API
Definition: Kernel.h:108
void construct(void *b) const
Definition: IInspector.h:59