| The Gaudi Framework v29r1 (5cd95fa2)

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

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
9 #include "GaudiKernel/IInterface.h"
10
15 class GAUDI_API IInspector : virtual public IInterface
16 {
17 public:
19 DeclareInterfaceID( IInspector, 1, 0 );
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;
41 const std::type_info& second;
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
IInspector::inspectByValue
StatusCode inspectByValue(const T &obj, const O *pOwner, const std::string &comment)
Inspect single item by its value (const)
Definition: IInspector.h:90
IInspector::_TT
Definition: IInspector.h:58
IInspector::_V
Definition: IInspector.h:47
IInspector::inspectContByRef
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
IInspector::IValue::release
virtual void release()
Definition: IInspector.h:32
IInspector::inspectByRef
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
IInspector::IValue::m_P
void * m_P
Definition: IInspector.h:27
IInspector::_V::m_O
T m_O
Definition: IInspector.h:49
std::type_info
std::string
STL class.
IInspector::_V::_V
_V(const T &v)
Definition: IInspector.h:52
IInspector::inspectContByValue
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
IInspector
Inspector base class.
Definition: IInspector.h:15
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:28
DeclareInterfaceID
#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
IInterface
Definition of the basic interface.
Definition: IInterface.h:277
IInspector::_V::construct
virtual void construct(void *b) const
Definition: IInspector.h:54
IInspector::Tag::second
const std::type_info & second
Definition: IInspector.h:41
IInspector::IValue
Definition: IInspector.h:24
IInspector::IValue::ptr
const void * ptr() const
Definition: IInspector.h:34
IInspector::Tag::first
long first
Definition: IInspector.h:40
gaudirun.s
string s
Definition: gaudirun.py:253
IInspector::Tag
Definition: IInspector.h:39
IInspector::_V::size
virtual long size() const
Definition: IInspector.h:53
IInspector::_TT::_TT
_TT()
Definition: IInspector.h:61
GAUDI_API
#define GAUDI_API
Definition: Kernel.h:110
IInspector::Tag::Tag
Tag(long f, const std::type_info &s)
Definition: IInspector.h:42
IInterface.h
IInspector::IValue::ptr
void * ptr()
Definition: IInspector.h:33