src
FWCore
Utilities
interface
OffsetToBase.h
Go to the documentation of this file.
1
#ifndef FWCore_Utilities_OffsetToBase_h
2
#define FWCore_Utilities_OffsetToBase_h
3
#include <cstddef>
4
#include <typeinfo>
5
6
/*
7
* For any class used in Views, RefToBase, or Ptr,
8
* class template OffsetToBase must be specialized for any class
9
* with multiple inheritance (i.e. with non-zero offset to
10
* at least one base class).
11
* A specialization would look something like this
12
* (in YourClass.h"
13
*
14
* #include "FWCore/Utilities/interface/OffsetToBase.h"
15
* namespace edm {
16
* template<>
17
* class OffsetToBase<YourClass> {
18
* public OffsetToBase() {}
19
* size_t offsetToBase(std::type_info const& baseTypeInfo) const {
20
* int const dummy = 0;
21
* YourClass const* object = reinterpret_cast<YourClass const*>(&dummy);
22
* void const* objectPtr = object;
23
* if(baseTypeInfo == typeid(BaseClass1)) {
24
* BaseClass1 const* base = object;
25
* void const* basePtr = base;
26
* return static_cast<char const*>(basePtr) - static_cast<char const*>(objectPtr);
27
* }
28
* if(baseTypeInfo == typeid(BaseClass2)) {
29
* ...
30
* }
31
* etc.
32
* }
33
* };
34
* }
35
*
36
*/
37
38
namespace
edm
{
39
template
<
typename
T>
40
class
OffsetToBase
{
41
public
:
42
OffsetToBase
() {}
43
size_t
offsetToBase
(std::type_info
const
& baseTypeInfo)
const
{
return
0; }
44
};
45
46
template
<
typename
T>
47
void
const
*
pointerToBase
(std::type_info
const
& baseTypeInfo,
T
const
* address) {
48
OffsetToBase<T>
offsetToBase;
49
int
offset
= offsetToBase.
offsetToBase
(baseTypeInfo);
50
void
const
* ptr = address;
51
return
static_cast<
char
const
*
>
(ptr) +
offset
;
52
}
53
}
// namespace edm
54
#endif
edm::OffsetToBase::OffsetToBase
OffsetToBase()
Definition:
OffsetToBase.h:42
runTheMatrix.const
const
Definition:
runTheMatrix.py:345
edm::OffsetToBase
Definition:
OffsetToBase.h:40
edm::OffsetToBase::offsetToBase
size_t offsetToBase(std::type_info const &baseTypeInfo) const
Definition:
OffsetToBase.h:43
edm
HLT enums.
Definition:
AlignableModifier.h:19
edm::pointerToBase
void const * pointerToBase(std::type_info const &baseTypeInfo, T const *address)
Definition:
OffsetToBase.h:47
T
long double T
Definition:
Basic3DVectorLD.h:48
hltrates_dqm_sourceclient-live_cfg.offset
offset
Definition:
hltrates_dqm_sourceclient-live_cfg.py:83
Generated for CMSSW Reference Manual by
1.8.14