| # Gaudi Framework, version v25r0 |

Home |  | Generated: Mon Feb 17 2014

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

- File List
- File Members

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:
19 DeclareInterfaceID(IInspector,1,0);
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