ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Database
TPTools
TPTools
ITPConverter.h
Go to the documentation of this file.
1
// -*- c++ -*-
2
3
/*
4
Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
5
*/
6
7
#ifndef TPTOOLS_ITPConverter_H
8
#define TPTOOLS_ITPConverter_H 1
9
16
17
#include "
AthenaKernel/ITPCnvBase.h
"
18
#include "
AthenaPoolUtilities/TPObjRef.h
"
19
20
#include <typeinfo>
21
#include <typeindex>
22
#include <string>
23
24
25
class
MsgStream;
26
class
TopLevelTPCnvBase
;
27
31
class
ITPConverter
:
public
ITPCnvBase
32
{
33
protected
:
34
ITPConverter
() {}
35
public
:
36
virtual
~ITPConverter
() =
default
;
37
44
virtual
void
setTopConverter
(
TopLevelTPCnvBase
*
topConverter
,
45
const
TPObjRef::typeID_t
& TPtypeID ) = 0;
46
52
virtual
void
setRuntimeTopConverter
(
TopLevelTPCnvBase
*
topConverter
) = 0;
53
57
virtual
TopLevelTPCnvBase
*
topConverter
() {
return
0; }
58
virtual
const
TopLevelTPCnvBase
*
topConverter
()
const
{
return
0; }
59
63
virtual
const
TPObjRef::typeID_t
&
typeID
()
const
= 0;
64
69
virtual
const
std::type_info&
transBaseTInfo
()
const
= 0;
70
72
virtual
void
reservePStorage
(
size_t
size
) = 0;
73
82
virtual
void
converterNotFound
(
const
std::type_info& converterType,
83
ITPConverter
*c,
84
const
std::string& typeName,
85
MsgStream& log )
const
;
86
95
virtual
void
converterNotFound
(
unsigned
typeID
,
96
ITPConverter
*c,
97
const
std::string& typeName,
98
MsgStream& log )
const
;
99
};
100
101
102
103
104
//-------------- TPConverterTypeMap<CONVERTER_BASE> -------------
105
#include <map>
106
111
template
<
class
CONVERTER_BASE>
112
class
TPConverterTypeMap
{
113
public
:
114
typedef
std::map<const std::type_index, CONVERTER_BASE*>
TId_Map_t
;
115
typedef
typename
TId_Map_t::iterator
iterator
;
116
117
TPConverterTypeMap
() {}
118
123
CONVERTER_BASE *
findConverter
(
const
std::type_info &objTypeInfo)
const
;
124
129
void
addConverter
(CONVERTER_BASE *converter,
130
const
std::type_info &objTypeInfo);
131
133
iterator
begin
() {
return
m_cnvRegistry
.begin(); }
134
136
iterator
end
() {
return
m_cnvRegistry
.end(); }
137
138
protected
:
139
TId_Map_t
m_cnvRegistry
;
140
};
141
142
143
144
145
146
template
<
class
CONVERTER_BASE>
147
inline
148
CONVERTER_BASE *
149
TPConverterTypeMap<CONVERTER_BASE>
150
::findConverter
(
const
std::type_info &objTypeInfo)
const
151
{
152
typename
TId_Map_t::const_iterator iter =
m_cnvRegistry
.find( std::type_index(objTypeInfo) );
153
return
(iter ==
m_cnvRegistry
.end())?
154
0 : iter->second;
155
}
156
157
158
template
<
class
CONVERTER_BASE>
159
inline
160
void
161
TPConverterTypeMap<CONVERTER_BASE>
162
::addConverter
(CONVERTER_BASE *converter,
const
std::type_info &objTypeInfo)
163
{
164
m_cnvRegistry
[std::type_index(objTypeInfo)] = converter;
165
}
166
167
168
169
#endif
ITPCnvBase.h
size
size_t size() const
Number of registered mappings.
TPObjRef.h
ITPCnvBase
Definition
ITPCnvBase.h:24
ITPConverter::reservePStorage
virtual void reservePStorage(size_t size)=0
Reserve 'size' elements for persistent storage.
ITPConverter::topConverter
virtual const TopLevelTPCnvBase * topConverter() const
Definition
ITPConverter.h:58
ITPConverter::transBaseTInfo
virtual const std::type_info & transBaseTInfo() const =0
return C++ type id of the common base transient type for all converters for a group of polymorphic ty...
ITPConverter::ITPConverter
ITPConverter()
Definition
ITPConverter.h:34
ITPConverter::converterNotFound
virtual void converterNotFound(const std::type_info &converterType, ITPConverter *c, const std::string &typeName, MsgStream &log) const
method called when the right TP converter was not found during writing
Definition
ITPConverter.cxx:22
ITPConverter::setRuntimeTopConverter
virtual void setRuntimeTopConverter(TopLevelTPCnvBase *topConverter)=0
Set runtime top-level converter - usually it is the owning TL converter, but in case of extended obje...
ITPConverter::typeID
virtual const TPObjRef::typeID_t & typeID() const =0
Return TP typeID for persistent objects produced by this converter.
ITPConverter::topConverter
virtual TopLevelTPCnvBase * topConverter()
return the top-level converter for this elemental TP converter
Definition
ITPConverter.h:57
ITPConverter::setTopConverter
virtual void setTopConverter(TopLevelTPCnvBase *topConverter, const TPObjRef::typeID_t &TPtypeID)=0
Set which top-level converter owns this elemental converter, and what TPtypeID was assigned to the pe...
ITPConverter::~ITPConverter
virtual ~ITPConverter()=default
TPConverterTypeMap
class TPConverterTypeMap Converter registry template: a map from type_info to the appropriate convert...
Definition
ITPConverter.h:112
TPConverterTypeMap::m_cnvRegistry
TId_Map_t m_cnvRegistry
map of the converters, indexed by type_index
Definition
ITPConverter.h:139
TPConverterTypeMap::addConverter
void addConverter(CONVERTER_BASE *converter, const std::type_info &objTypeInfo)
Add a new converter to the map.
Definition
ITPConverter.h:162
TPConverterTypeMap::begin
iterator begin()
Definition
ITPConverter.h:133
TPConverterTypeMap::findConverter
CONVERTER_BASE * findConverter(const std::type_info &objTypeInfo) const
Find converter for a given C++ type info.
Definition
ITPConverter.h:150
TPConverterTypeMap::end
iterator end()
Definition
ITPConverter.h:136
TPConverterTypeMap::TPConverterTypeMap
TPConverterTypeMap()
Definition
ITPConverter.h:117
TPConverterTypeMap::iterator
TId_Map_t::iterator iterator
Definition
ITPConverter.h:115
TPConverterTypeMap::TId_Map_t
std::map< const std::type_index, CONVERTER_BASE * > TId_Map_t
Definition
ITPConverter.h:114
TopLevelTPCnvBase
Base class for top-level TP converters.
Definition
TopLevelTPCnvBase.h:32
TPObjRef::typeID_t
This structure holds an ID of a persistent type.
Definition
TPObjRef.h:31
Generated on
for ATLAS Offline Software by
1.17.0