ATLAS Offline Software
TypeConverter.h
Go to the documentation of this file.
1 // This file's extension implies that it's C, but it's really -*- C++ -*-.
2 
3 /*
4  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
5 */
6 
7 // $Id$
16 #ifndef D3PDMAKERUTILS_TYPECONVERTER_H
17 #define D3PDMAKERUTILS_TYPECONVERTER_H
18 
19 
20 #include "GaudiKernel/StatusCode.h"
21 #include <typeinfo>
22 #include <cassert>
23 #include <vector>
24 namespace SG {
25  class BaseInfoBase;
26 }
27 
28 
29 namespace D3PD {
30 
31 
45 {
46 public:
52  TypeConverter();
53 
54 
67  StatusCode init (const std::type_info& src_ti,
68  const std::type_info& dst_ti);
69 
70 
88  StatusCode init (const std::type_info& src_ti,
89  const std::vector<const std::type_info*>& dst_tis,
90  size_t& which);
91 
92 
105  template <typename T>
106  StatusCode init (const std::type_info& src_ti);
107 
108 
117  const void* convertUntyped (const void* p) const;
118 
119 
130  template <class T>
131  const T* convert (const void* p) const;
132 
133 
137  bool isValid() const;
138 
139 
141  const std::type_info& srcTypeinfo() const;
142 
143 
145  const std::type_info& dstTypeinfo() const;
146 
148  std::string srcName() const;
149 
151  std::string dstName() const;
152 
153 
154 private:
169  StatusCode tryInit (const std::type_info& src_ti,
170  const std::type_info& dst_ti);
171 
172 
174  const std::type_info* m_srcTypeinfo;
175 
177  const std::type_info* m_dstTypeinfo;
178 
181 
184 
185  enum Strategy {
188 
191 
194 
196  DST_BASE
197  };
198 
201 };
202 
203 
204 } // namespace D3PD
205 
206 
208 
209 
210 #endif // not D3PDUTILS_TYPECONVERTER_H
D3PD::TypeConverter::srcTypeinfo
const std::type_info & srcTypeinfo() const
Return the configured source type.
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
SG
Forward declaration.
Definition: CaloCellPacker_400_500.h:32
D3PD::TypeConverter::dstName
std::string dstName() const
Return the name of the destination type, or an empty string.
Definition: TypeConverter.cxx:151
D3PD::TypeConverter::SRC_BASE
@ SRC_BASE
Destination is a base of source — use source BaseInfo.
Definition: TypeConverter.h:193
D3PD::TypeConverter::m_strategy
Strategy m_strategy
Strategy to use for the conversion.
Definition: TypeConverter.h:200
D3PD::TypeConverter::m_dstTypeinfo
const std::type_info * m_dstTypeinfo
The destination type.
Definition: TypeConverter.h:177
D3PD::TypeConverter
This is helper for converting between pointers of different types, given dynamically by std::type_inf...
Definition: TypeConverter.h:45
D3PD::TypeConverter::init
StatusCode init(const std::type_info &src_ti, const std::type_info &dst_ti)
Initialize the converter.
Definition: TypeConverter.cxx:51
D3PD::TypeConverter::srcName
std::string srcName() const
Return the name of the source type, or an empty string.
Definition: TypeConverter.cxx:141
D3PD::TypeConverter::convertUntyped
const void * convertUntyped(const void *p) const
Convert pointer.
Definition: TypeConverter.cxx:116
D3PD
Block filler tool for noisy FEB information.
Definition: InnerDetector/InDetMonitoring/InDetGlobalMonitoring/macros/EnhancedPrimaryVertexMonitoring/TrigD3PD/ChainGroup.h:21
D3PD::TypeConverter::m_srcTypeinfo
const std::type_info * m_srcTypeinfo
The source type.
Definition: TypeConverter.h:174
D3PD::TypeConverter::convert
const T * convert(const void *p) const
Convert pointer.
D3PD::TypeConverter::TypeConverter
TypeConverter()
Default constructor.
Definition: TypeConverter.cxx:29
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
python.Utils.unixtools.which
def which(filename, env=os.environ)
UNIX-style which ---------------------------------------------------------—.
Definition: unixtools.py:39
D3PD::TypeConverter::isValid
bool isValid() const
Test to see if this converter has been properly initialized.
D3PD::TypeConverter::INVALID
@ INVALID
No valid conversion has been configured.
Definition: TypeConverter.h:187
D3PD::TypeConverter::m_srcBIB
const SG::BaseInfoBase * m_srcBIB
BaseInfo for the source type.
Definition: TypeConverter.h:180
TypeConverter.icc
D3PD::TypeConverter::Strategy
Strategy
Definition: TypeConverter.h:185
D3PD::TypeConverter::IDENTICAL
@ IDENTICAL
Source and destination types are identical.
Definition: TypeConverter.h:190
SG::BaseInfoBase
The non-template portion of the BaseInfo implementation.
Definition: Control/AthenaKernel/AthenaKernel/BaseInfo.h:451
D3PD::TypeConverter::DST_BASE
@ DST_BASE
Source is a base of destination — use destination BaseInfo.
Definition: TypeConverter.h:196
D3PD::TypeConverter::dstTypeinfo
const std::type_info & dstTypeinfo() const
Return the configured destination type.
D3PD::TypeConverter::tryInit
StatusCode tryInit(const std::type_info &src_ti, const std::type_info &dst_ti)
Initialize the converter.
Definition: TypeConverter.cxx:172
D3PD::TypeConverter::init
StatusCode init(const std::type_info &src_ti)
Alternate form of init, passing the destination type as a template argument.
D3PD::TypeConverter::m_dstBIB
const SG::BaseInfoBase * m_dstBIB
BaseInfo for the destination type.
Definition: TypeConverter.h:183