Loading [MathJax]/extensions/tex2jax.js
The Gaudi Framework  v31r0 (aeb156f0)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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 public:
19 
20  enum { Mutable = 1 << 1, Const = 1 << 2 };
21 
22 protected:
23  class IValue {
24  protected:
25  void* m_P;
26  IValue() = default;
27 
28  public:
29  virtual ~IValue() = default;
30  virtual void release() { delete this; }
31  void* ptr() { return m_P; }
32  const void* ptr() const { return m_P; }
33  virtual long size() const = 0;
34  virtual void construct( void* buffer ) const = 0;
35  };
36 
37  struct Tag {
38  long first;
40  Tag( long f, const std::type_info& s ) : first( f ), second( s ) {}
41  };
42 
43 private:
44  template <class T>
45  class _V : public IValue {
46  T m_O;
47 
48  public:
49  _V( const T& v ) : m_O( v ) { m_P = &m_O; }
50  virtual long size() const { return sizeof( T ); }
51  virtual void construct( void* b ) const { ::new ( b ) T(); }
52  };
53 
54  template <class T>
55  class _TT : public Tag {
56  public:
57  _TT() : Tag( sizeof( T ), typeid( T ) ) {}
58  };
59 
60 protected:
61  // Referenced implementation of the IInspector interface:
63  virtual StatusCode inspectByRef( const void* pObj, const Tag& typ, void* pOwner, const Tag& otag,
64  const std::string& comment, long flag ) = 0;
66  virtual StatusCode inspectByValue( IValue* pObj, const Tag& typ, void* pOwner, const Tag& oTag,
67  const std::string& comment ) = 0;
69  virtual StatusCode inspectContByRef( const void* pObj, const Tag& tag, const Tag& rtag, const Tag& vtag,
70  const void* pOwner, const Tag& otag, const std::string& comment,
71  long flags ) = 0;
73  virtual StatusCode inspectContByValue( IValue* pObj, const Tag& tag, const Tag& rtag, const Tag& vtag,
74  const void* pOwner, const Tag& otag, const std::string& comment ) = 0;
75 
76 public:
77  // User interface of the IInspector interface
79  template <class T, class O>
80  StatusCode inspectByRef( const T* pObj, const O* pOwner, const std::string& comment, long flag = Mutable ) {
81  return inspectByRef( pObj, _TT<T>(), (void*)pOwner, _TT<O>(), comment, flag );
82  }
84  template <class T, class O>
85  StatusCode inspectByValue( const T& obj, const O* pOwner, const std::string& comment ) {
86  return inspectByValue( new _V<T>( obj ), _TT<T>(), (void*)pOwner, _TT<O>(), comment );
87  }
89  template <class T, class O>
90  StatusCode inspectContByRef( const T* pObj, const O* pOwner, const std::string& comment, long flag = Mutable ) {
91  typedef typename T::value_type _VVV;
92  typedef typename T::value_type _TTT;
93  // Unfortunately this is not implemented on G++:
94  // typedef typename T::allocator_type::value_type _TTT;
95  return inspectContByRef( (void*)pObj, _TT<T>(), _TT<_VVV>(), _TT<_TTT>(), (void*)pOwner, _TT<O>(), comment, flag );
96  }
98  template <class T, class O>
99  StatusCode inspectContByValue( const T& obj, const O* pOwner, const std::string& comment ) {
100  typedef typename T::value_type _VVV;
101  typedef typename T::value_type _TTT;
102  // Unfortunately this is not implemented on G++:
103  // typedef typename T::allocator_type::value_type _TTT;
104  return inspectContByValue( new _V<T>( obj ), _TT<T>(), _TT<_VVV>(), _TT<_TTT>(), (void*)pOwner, _TT<O>(), comment );
105  }
106 };
107 #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:85
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:90
virtual void release()
Definition: IInspector.h:30
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:80
constexpr auto size(const C &c) noexcept(noexcept(c.size())) -> decltype(c.size())
STL class.
_V(const T &v)
Definition: IInspector.h:49
StatusCode inspectContByValue(const T &obj, const O *pOwner, const std::string &comment)
Inspect container of object items by its value (const)
Definition: IInspector.h:99
Inspector base class.
Definition: IInspector.h:15
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:50
#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:244
virtual void construct(void *b) const
Definition: IInspector.h:51
const std::type_info & second
Definition: IInspector.h:39
const void * ptr() const
Definition: IInspector.h:32
string s
Definition: gaudirun.py:312
virtual long size() const
Definition: IInspector.h:50
#define GAUDI_API
Definition: Kernel.h:71
Tag(long f, const std::type_info &s)
Definition: IInspector.h:40