test
Main Page
Namespaces
Classes
Package Documentation
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Pages
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 <typeinfo>
4
5
/*
6
* For any class used in Views, RefToBase, or Ptr,
7
* class template OffsetToBase must be specialized for any class
8
* with multiple inheritance (i.e. with non-zero offset to
9
* at least one base class).
10
* A specialization would look something like this
11
* (in YourClass.h"
12
*
13
* #include "FWCore/Utilities/interface/OffsetToBase.h"
14
* namespace edm {
15
* template<>
16
* class OffsetToBase<YourClass> {
17
* public OffsetToBase() {}
18
* size_t offsetToBase(std::type_info const& baseTypeInfo) const {
19
* int const dummy = 0;
20
* YourClass const* object = reinterpret_cast<YourClass const*>(&dummy);
21
* void const* objectPtr = object;
22
* if(baseTypeInfo == typeid(BaseClass1)) {
23
* BaseClass1 const* base = object;
24
* void const* basePtr = base;
25
* return static_cast<char const*>(basePtr) - static_cast<char const*>(objectPtr);
26
* }
27
* if(baseTypeInfo == typeid(BaseClass2)) {
28
* ...
29
* }
30
* etc.
31
* }
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
{
44
return
0;
45
}
46
};
47
48
template
<
typename
T>
49
void
const
*
pointerToBase
(std::type_info
const
& baseTypeInfo,
T
const
* address) {
50
OffsetToBase<T>
offsetToBase;
51
int
offset
= offsetToBase.
offsetToBase
(baseTypeInfo);
52
void
const
* ptr = address;
53
return
static_cast<
char
const
*
>
(ptr) + offset;
54
}
55
}
56
#endif
edm::OffsetToBase::OffsetToBase
OffsetToBase()
Definition:
OffsetToBase.h:42
edm::OffsetToBase
Definition:
OffsetToBase.h:40
edm::OffsetToBase::offsetToBase
size_t offsetToBase(std::type_info const &baseTypeInfo) const
Definition:
OffsetToBase.h:43
compareJSON.const
string const
Definition:
compareJSON.py:14
hltrates_dqm_sourceclient-live_cfg.offset
tuple offset
Definition:
hltrates_dqm_sourceclient-live_cfg.py:81
edm::pointerToBase
void const * pointerToBase(std::type_info const &baseTypeInfo, T const *address)
Definition:
OffsetToBase.h:49
T
long double T
Definition:
Basic3DVectorLD.h:57
Generated for CMSSW Reference Manual by
1.8.5