The Gaudi Framework  v29r0 (ff2e7097)
IInspector.h
Go to the documentation of this file.
1 #ifndef GAUDIKERNEL_IINSPECTOR_H
2 #define GAUDIKERNEL_IINSPECTOR_H
3 
4 // STL Include files
5 #include <string>
6 #include <typeinfo>
7 
8 // Framework Include files
10 
15 class GAUDI_API IInspector : virtual public IInterface
16 {
17 public:
20 
21  enum { Mutable = 1 << 1, Const = 1 << 2 };
22 
23 protected:
24  class IValue
25  {
26  protected:
27  void* m_P;
28  IValue() = default;
29 
30  public:
31  virtual ~IValue() = default;
32  virtual void release() { delete this; }
33  void* ptr() { return m_P; }
34  const void* ptr() const { return m_P; }
35  virtual long size() const = 0;
36  virtual void construct( void* buffer ) const = 0;
37  };
38 
39  struct Tag {
40  long first;
42  Tag( long f, const std::type_info& s ) : first( f ), second( s ) {}
43  };
44 
45 private:
46  template <class T>
47  class _V : public IValue
48  {
49  T m_O;
50 
51  public:
52  _V( const T& v ) : m_O( v ) { m_P = &m_O; }
53  virtual long size() const { return sizeof( T ); }
54  virtual void construct( void* b ) const { ::new ( b ) T(); }
55  };
56 
57  template <class T>
58  class _TT : public Tag
59  {
60  public:
61  _TT() : Tag( sizeof( T ), typeid( T ) ) {}
62  };
63 
64 protected:
65  // Referenced implementation of the IInspector interface:
67  virtual StatusCode inspectByRef( const void* pObj, const Tag& typ, void* pOwner, const Tag& otag,
68  const std::string& comment, long flag ) = 0;
70  virtual StatusCode inspectByValue( IValue* pObj, const Tag& typ, void* pOwner, const Tag& oTag,
71  const std::string& comment ) = 0;
73  virtual StatusCode inspectContByRef( const void* pObj, const Tag& tag, const Tag& rtag, const Tag& vtag,
74  const void* pOwner, const Tag& otag, const std::string& comment,
75  long flags ) = 0;
77  virtual StatusCode inspectContByValue( IValue* pObj, const Tag& tag, const Tag& rtag, const Tag& vtag,
78  const void* pOwner, const Tag& otag, const std::string& comment ) = 0;
79 
80 public:
81  // User interface of the IInspector interface
83  template <class T, class O>
84  StatusCode inspectByRef( const T* pObj, const O* pOwner, const std::string& comment, long flag = Mutable )
85  {
86  return inspectByRef( pObj, _TT<T>(), (void*)pOwner, _TT<O>(), comment, flag );
87  }
89  template <class T, class O>
90  StatusCode inspectByValue( const T& obj, const O* pOwner, const std::string& comment )
91  {
92  return inspectByValue( new _V<T>( obj ), _TT<T>(), (void*)pOwner, _TT<O>(), comment );
93  }
95  template <class T, class O>
96  StatusCode inspectContByRef( const T* pObj, const O* pOwner, const std::string& comment, long flag = Mutable )
97  {
98  typedef typename T::value_type _VVV;
99  typedef typename T::value_type _TTT;
100  // Unfortunately this is not implemented on G++:
101  // typedef typename T::allocator_type::value_type _TTT;
102  return inspectContByRef( (void*)pObj, _TT<T>(), _TT<_VVV>(), _TT<_TTT>(), (void*)pOwner, _TT<O>(), comment, flag );
103  }
105  template <class T, class O>
106  StatusCode inspectContByValue( const T& obj, const O* pOwner, const std::string& comment )
107  {
108  typedef typename T::value_type _VVV;
109  typedef typename T::value_type _TTT;
110  // Unfortunately this is not implemented on G++:
111  // typedef typename T::allocator_type::value_type _TTT;
112  return inspectContByValue( new _V<T>( obj ), _TT<T>(), _TT<_VVV>(), _TT<_TTT>(), (void*)pOwner, _TT<O>(), comment );
113  }
114 };
115 #endif // GAUDIKERNEL_IINSPECTOR_H
StatusCode inspectByValue(const T &obj, const O *pOwner, const std::string &comment)
Inspect single item by its value (const)
Definition: IInspector.h:90
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:96
virtual void release()
Definition: IInspector.h:32
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:84
STL class.
_V(const T &v)
Definition: IInspector.h:52
StatusCode inspectContByValue(const T &obj, const O *pOwner, const std::string &comment)
Inspect container of object items by its value (const)
Definition: IInspector.h:106
Inspector base class.
Definition: IInspector.h:15
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:28
#define DeclareInterfaceID(iface, major, minor)
Macro to declare the interface ID when using the new mechanism of extending and implementing interfac...
Definition: IInterface.h:13
Definition of the basic interface.
Definition: IInterface.h:277
virtual void construct(void *b) const
Definition: IInspector.h:54
const std::type_info & second
Definition: IInspector.h:41
const void * ptr() const
Definition: IInspector.h:34
string s
Definition: gaudirun.py:253
virtual long size() const
Definition: IInspector.h:53
#define GAUDI_API
Definition: Kernel.h:110
Tag(long f, const std::type_info &s)
Definition: IInspector.h:42