| The Gaudi Framework v28r2p1 (f1a77ff4)

- 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 <typeinfo>
6 #include <string>
7
8 // Framework Include files
9 #include "GaudiKernel/IInterface.h"
10
15 class GAUDI_API IInspector: virtual public IInterface {
16 public:
18 DeclareInterfaceID(IInspector,1,0);
19
20 enum { Mutable = 1<<1, Const = 1<<2 };
21
22 protected:
23
24 class IValue {
25 protected:
26 void* m_P;
27 IValue() = default;
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;
39 const std::type_info& second;
40 Tag(long f, const std::type_info& s) : first(f), second(s) { }
41 };
42
43 private:
44 template <class T> class _V : public IValue {
45 T m_O;
46 public:
47 _V(const T& v) : m_O(v) { m_P = &m_O; }
48 virtual long size() const { return sizeof(T); }
49 virtual void construct(void* b) const { ::new(b) T(); }
50 };
51
52 template <class T> class _TT : public Tag {
53 public: _TT() : Tag(sizeof(T), typeid(T)) { }
54 };
55
56 protected:
57 // Referenced implementation of the IInspector interface:
59 virtual StatusCode inspectByRef(const void* pObj, const Tag& typ, void* pOwner, const Tag& otag, const std::string& comment, long flag) = 0;
61 virtual StatusCode inspectByValue(IValue* pObj, const Tag& typ, void* pOwner, const Tag& oTag, const std::string& comment) = 0;
63 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;
65 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;
66
67 public:
68 // User interface of the IInspector interface
70 template < class T, class O >
71 StatusCode inspectByRef(const T* pObj, const O* pOwner, const std::string& comment, long flag=Mutable) {
72 return inspectByRef(pObj, _TT<T>(), (void*)pOwner, _TT<O>(), comment, flag);
73 }
75 template < class T, class O >
76 StatusCode inspectByValue(const T& obj, const O* pOwner, const std::string& comment) {
77 return inspectByValue(new _V<T>(obj), _TT<T>(), (void*)pOwner, _TT<O>(), comment);
78 }
80 template < class T, class O >
81 StatusCode inspectContByRef( const T* pObj, const O* pOwner, const std::string& comment, long flag=Mutable) {
82 typedef typename T::value_type _VVV;
83 typedef typename T::value_type _TTT;
84 // Unfortunately this is not implemented on G++:
85 // typedef typename T::allocator_type::value_type _TTT;
86 return inspectContByRef((void*)pObj, _TT<T>(), _TT<_VVV>(), _TT<_TTT>(), (void*)pOwner, _TT<O>(), comment, flag);
87 }
89 template < class T, class O >
90 StatusCode inspectContByValue( const T& obj, const O* pOwner, const std::string& comment) {
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 inspectContByValue(new _V<T>(obj), _TT<T>(), _TT<_VVV>(), _TT<_TTT>(), (void*)pOwner, _TT<O>(), comment);
96 }
97 };
98 #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:76
IInspector::_TT
Definition: IInspector.h:52
IInspector::_V
Definition: IInspector.h:44
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:14
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:81
IInspector::IValue::release
virtual void release()
Definition: IInspector.h:30
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:71
IInspector::IValue::m_P
void * m_P
Definition: IInspector.h:26
IInspector::_V::m_O
T m_O
Definition: IInspector.h:45
std::type_info
std::string
STL class.
IInspector::_V::_V
_V(const T &v)
Definition: IInspector.h:47
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:90
IInspector
Inspector base class.
Definition: IInspector.h:15
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
IInterface
Definition of the basic interface.
Definition: IInterface.h:234
IInspector::_V::construct
virtual void construct(void *b) const
Definition: IInspector.h:49
IInspector::Tag::second
const std::type_info & second
Definition: IInspector.h:39
IInspector::IValue
Definition: IInspector.h:24
IInspector::IValue::ptr
const void * ptr() const
Definition: IInspector.h:32
IInspector::Tag::first
long first
Definition: IInspector.h:38
gaudirun.s
string s
Definition: gaudirun.py:245
IInspector::Tag
Definition: IInspector.h:37
IInspector::_V::size
virtual long size() const
Definition: IInspector.h:48
IInspector::_TT::_TT
_TT()
Definition: IInspector.h:53
GAUDI_API
#define GAUDI_API
Definition: Kernel.h:107
IInspector::Tag::Tag
Tag(long f, const std::type_info &s)
Definition: IInspector.h:40
IInterface.h
IInspector::IValue::ptr
void * ptr()
Definition: IInspector.h:31