ATLAS Offline Software
Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | List of all members
AthenaConverterTLPExtension Class Referenceabstract

This class is used to add functionality to a standard AthenaConverter. More...

#include <AthenaConverterTLPExtension.h>

Inheritance diagram for AthenaConverterTLPExtension:
Collaboration diagram for AthenaConverterTLPExtension:

Public Member Functions

 AthenaConverterTLPExtension ()
 Constructor. More...
 
virtual ~AthenaConverterTLPExtension ()
 Destructor. More...
 
virtual const TokenwriteObject (const std::string &, const std::string &)
 Writes the extending persistent object created by this converter Called from the EXTENDED (principal) Athena converter Implemented only in EXTENDING Athena converters. More...
 
virtual void readObject (const std::string &)
 Read the extending object. More...
 
virtual AthenaConverterTLPExtensionclone ()
 Clone this Athena Converter. More...
 
virtual void wasClonedFrom (AthenaConverterTLPExtension *)
 Remember the original converter that this one was cloned from. More...
 
virtual bool needsCloning () const
 Find out if this converter needs to be cloned Returns true if this converter was already registered once. More...
 
virtual const std::string name () const
 Get name of this converter (anything that identifies it) More...
 
virtual TopLevelTPCnvBasegetTopLevelTPCnv ()=0
 returns the main top-level TP converter More...
 
unsigned short getTPCnvID ()
 Returns the ID of the main top-level TP converter. More...
 
TopLevelTPCnvBasegetTopLevelTPCnvForReading ()
 returns the current top-level TP converter. More...
 
void usingTPCnvForReading (TopLevelTPCnvBase &cnv)
 Sets top-level TP converter to be used for reading the next object. More...
 
void resetTPCnvForReading ()
 Reset to 0 the TL TP converter for reading. More...
 
virtual void readExtendingObjects (void *baseObj)
 Read all component persistent objects. More...
 
virtual void deletePersistentObjects ()
 Delete persistent objects held by attached extending converters (used mainly in case of abort) More...
 
virtual bool registerExtendingCnv (AthenaConverterTLPExtension *cnv)
 Register extending converter (that is, another converter that will extent this converter) and all his elemental converters. More...
 

Protected Types

typedef std::map< unsigned, AthenaConverterTLPExtension * > extCnvMap_t
 
typedef std::map< TopLevelTPCnvBase *, extCnvMap_t * > extCnvMapMap_t
 

Protected Member Functions

void usingTPCnvForReading (void *cnv)
 

Protected Attributes

extCnvMap_t m_extendingConverters
 map of Athena converters extending this one More...
 
extCnvMapMap_t m_extCnvMapMap
 
TopLevelTPCnvBasem_TLCnvForReading
 additional Top Level TP converter used only for reading tells which converter is used in case of reading old versions (as different versions have different converters) NOT owned byt his class More...
 
std::vector< AthenaConverterTLPExtension * > m_clonedExtendingCnvs
 list of duplicated converters to delete at the end held in the original converter More...
 

Detailed Description

This class is used to add functionality to a standard AthenaConverter.

AthenaConverterTLPExtension does not work standalone and should not be used directly. T_AthenaPoolExtendingCnv, which inherits from it, is the enhanced AthenaPool converter base inteded to be used to implement new Athena converters.

AthenaConverterTLPExtension provides:

AthenaConverterTLPExtension defines interface for both extended and extending converters - some methods are implemented only in one converter type

Definition at line 42 of file AthenaConverterTLPExtension.h.

Member Typedef Documentation

◆ extCnvMap_t

Definition at line 133 of file AthenaConverterTLPExtension.h.

◆ extCnvMapMap_t

Definition at line 138 of file AthenaConverterTLPExtension.h.

Constructor & Destructor Documentation

◆ AthenaConverterTLPExtension()

AthenaConverterTLPExtension::AthenaConverterTLPExtension ( )
inline

Constructor.

Definition at line 46 of file AthenaConverterTLPExtension.h.

46 : m_TLCnvForReading(0) {}

◆ ~AthenaConverterTLPExtension()

AthenaConverterTLPExtension::~AthenaConverterTLPExtension ( )
virtual

Destructor.

Definition at line 164 of file AthenaConverterTLPExtension.cxx.

165 {
166  // cout << "Deleting " << m_clonedExtendingCnvs.size() << " extending converters" << endl;
167  for( size_t c = 0; c < m_clonedExtendingCnvs.size(); c++ )
168  delete m_clonedExtendingCnvs[c];
169  for( extCnvMapMap_t::const_iterator mmiter = m_extCnvMapMap.begin();
170  mmiter != m_extCnvMapMap.end(); ++mmiter ) {
171  delete mmiter->second;
172  }
173 
174 }

Member Function Documentation

◆ clone()

virtual AthenaConverterTLPExtension* AthenaConverterTLPExtension::clone ( )
inlinevirtual

Clone this Athena Converter.

Returns the cloned instance

Definition at line 70 of file AthenaConverterTLPExtension.h.

70 { return 0; }

◆ deletePersistentObjects()

void AthenaConverterTLPExtension::deletePersistentObjects ( )
virtual

Delete persistent objects held by attached extending converters (used mainly in case of abort)

Definition at line 148 of file AthenaConverterTLPExtension.cxx.

149 {
150  for( extCnvMap_t::const_iterator cnv = m_extendingConverters.begin();
151  cnv != m_extendingConverters.end(); ++cnv ) {
152  cnv->second->deletePersistentObjects();
153  }
154  for( size_t c = 0; c < m_clonedExtendingCnvs.size(); c++ )
156 
158  // Can not do that - sometimes the converter is an automatic variable that is gone already
159  //if( m_TLCnvForReading ) m_TLCnvForReading->deleteTLPersObject();
160 }

◆ getTopLevelTPCnv()

virtual TopLevelTPCnvBase* AthenaConverterTLPExtension::getTopLevelTPCnv ( )
pure virtual

returns the main top-level TP converter

  • To be implemented in the actual Converter implementation *

Implemented in JetCollectionCnv, TrackCollectionCnv, SegmentCollectionCnv, and VxContainerCnv.

◆ getTopLevelTPCnvForReading()

TopLevelTPCnvBase* AthenaConverterTLPExtension::getTopLevelTPCnvForReading ( )
inline

returns the current top-level TP converter.

This converter may be different from the main one in case of schema evolution

Definition at line 100 of file AthenaConverterTLPExtension.h.

100 { return m_TLCnvForReading; }

◆ getTPCnvID()

unsigned short AthenaConverterTLPExtension::getTPCnvID ( )

Returns the ID of the main top-level TP converter.

Definition at line 23 of file AthenaConverterTLPExtension.cxx.

23  {
24  return getTopLevelTPCnv()->getConverterID();
25 }

◆ name()

virtual const std::string AthenaConverterTLPExtension::name ( ) const
inlinevirtual

Get name of this converter (anything that identifies it)

Returns
Name of this converter

Definition at line 85 of file AthenaConverterTLPExtension.h.

85 { return "Extended Athena TP Converter"; }

◆ needsCloning()

virtual bool AthenaConverterTLPExtension::needsCloning ( ) const
inlinevirtual

Find out if this converter needs to be cloned Returns true if this converter was already registered once.

Definition at line 80 of file AthenaConverterTLPExtension.h.

80 { return false; }

◆ readExtendingObjects()

void AthenaConverterTLPExtension::readExtendingObjects ( void *  baseObj)
virtual

Read all component persistent objects.

Parameters
baseObj[IN] pointer to the principal persistent object holding the list of tokens for all component persistent objects to read

Definition at line 99 of file AthenaConverterTLPExtension.cxx.

100 {
101  // m_TLCnvForReading may be 0 if reading pre-TP object
102  if( m_TLCnvForReading ) {
104  if( tokens && tokens->size() ) {
105  // find which extending converter "set" to use
106  extCnvMap_t *extendingConverters;
108  // use the newest TP converters
109  extendingConverters = &m_extendingConverters;
110  } else {
111  extCnvMapMap_t::const_iterator extCnvMapIter = m_extCnvMapMap.find(m_TLCnvForReading);
112  if( extCnvMapIter == m_extCnvMapMap.end() ) {
113  throw std::runtime_error("Extending TP converter not available");
114  }
115  extendingConverters = extCnvMapIter->second;
116  }
117  // load the remaining "pieces" of this object
118  for( TPCnvTokenList_p1::const_iterator it = tokens->begin(); it != tokens->end(); ++it ) {
119  if( it->token().size() < 36 ) {
120  ostringstream err;
121  err << "Corrupted Token in the list of extensions. Token='" << it->token() << "'"
122  << " CnvID=" << it->converterID() << ", Token list size=" << tokens->size();
123  throw std::runtime_error(err.str());
124  }
125  extCnvMap_t::const_iterator cnv = extendingConverters->find( it->converterID() );
126  if( cnv == extendingConverters->end() ) {
127  ostringstream err;
128  err << "Extending TP converter not loaded! "
129  << "missing ExtCnvID=" << it->converterID()
130  << " corresponding POOL token: " << it->token();
131  throw std::runtime_error(err.str());
132  }
133 // std::cout << "--->>--- readExtendingObjects: "
134 // << " converter ID=" << it->converterID()
135 // << " token=" << it->token() << ", AP converter=" << cnv->second << std::endl;
136 
137  cnv->second->readObject( it->token() );
138  TopLevelTPCnvBase *extTPCnv = cnv->second->getTopLevelTPCnvForReading();
140  }
141  }
142  }
143 }

◆ readObject()

virtual void AthenaConverterTLPExtension::readObject ( const std::string &  )
inlinevirtual

Read the extending object.

Parameters
token[IN] Token of the object to read

Definition at line 65 of file AthenaConverterTLPExtension.h.

65 { }

◆ registerExtendingCnv()

bool AthenaConverterTLPExtension::registerExtendingCnv ( AthenaConverterTLPExtension cnv)
virtual

Register extending converter (that is, another converter that will extent this converter) and all his elemental converters.

Parameters
cnv[IN] pointer to extending Athena converter

Reimplemented in AthenaPoolCnvTPExtension.

Definition at line 28 of file AthenaConverterTLPExtension.cxx.

29 {
30  // check if all converter IDs are unique
31  int extendingTPLCnvID = extending_converter->getTPCnvID();
32  if( extendingTPLCnvID == this->getTPCnvID()
33  || m_extendingConverters.find( extendingTPLCnvID ) != m_extendingConverters.end() ) {
34  ostringstream error;
35  error << "Conflicting TP converter IDs when registering extending Athena Converter. ID=" << extendingTPLCnvID;
36  throw runtime_error( error.str() );
37  }
38  AthenaConverterTLPExtension *cloned_converter;
39  if( ! extending_converter->needsCloning() ) {
40  cloned_converter = extending_converter;
41  // cout << " TPCNVINFO: TP converter not cloned CLID=" << cnv->name() << endl;
42  } else {
43  // get a private converter copy
44  cloned_converter = extending_converter->clone();
45  if( !cloned_converter ) {
46  ostringstream error;
47  error << "Extending TP converter neeeds to define clone() method. Converter: " << extending_converter->name();
48  throw runtime_error( error.str() );
49  }
50  //cout << " TPCNVINFO: Cloned extending TP converter " << " Converter CLID=" << extending_converter->name() << endl;
51  m_clonedExtendingCnvs.push_back( cloned_converter );
52  }
53  cloned_converter->wasClonedFrom( extending_converter );
54  m_extendingConverters[ extendingTPLCnvID ] = cloned_converter;
55  return true;
56 }

◆ resetTPCnvForReading()

void AthenaConverterTLPExtension::resetTPCnvForReading ( )
inline

Reset to 0 the TL TP converter for reading.

Prevents the use of the previous TP converter if none was set before reading the next object Called automatically after reading an object.

Definition at line 111 of file AthenaConverterTLPExtension.h.

111 { m_TLCnvForReading = 0; }

◆ usingTPCnvForReading() [1/2]

void AthenaConverterTLPExtension::usingTPCnvForReading ( TopLevelTPCnvBase cnv)

Sets top-level TP converter to be used for reading the next object.

Parameters
cnv[IN] top-level TP converter to be used for reading the next

Definition at line 65 of file AthenaConverterTLPExtension.cxx.

66 {
67  m_TLCnvForReading = &baseTLPcnv;
68 
70  // we are reading an old class version
71  if( m_extendingConverters.size()
72  && m_extCnvMapMap.find( m_TLCnvForReading ) == m_extCnvMapMap.end() ) {
73  // it is first time we use this TLP converter (for the old version)
74  extCnvMap_t *newCnvMap = new extCnvMap_t;
75  m_extCnvMapMap[ m_TLCnvForReading ] = newCnvMap;
76 
77  // copy clones of all extending converters to a new converter map
78  for( extCnvMap_t::const_iterator cnvI = m_extendingConverters.begin();
79  cnvI != m_extendingConverters.end(); ++cnvI ) {
80  AthenaConverterTLPExtension *cloned_converter = cnvI->second->clone();
81  if( !cloned_converter ) {
82  // basically panicking, this is not a runtime exception but an incomplete converter implementation
83  ostringstream error;
84  error << " TPCNVINFO: ERROR! This extending TP converter does not define clone() method. "
85  << " Converter: " << cnvI->second->name();
86  cerr << error.str() << endl;
87  throw runtime_error( error.str() );
88  }
89  m_clonedExtendingCnvs.push_back( cloned_converter );
90  cloned_converter->wasClonedFrom( cnvI->second );
91  (*newCnvMap)[ cloned_converter->getTPCnvID() ] = cloned_converter;
92  // this would be only necessary for writing, but we don't write old versions
93  //cloned_converter->getTopLevelTPCnv()->addTPConvertersTo( this->getTopLevelTPCnv() );
94  }
95  }
96  }
97 }

◆ usingTPCnvForReading() [2/2]

void AthenaConverterTLPExtension::usingTPCnvForReading ( void *  cnv)
protected

Definition at line 59 of file AthenaConverterTLPExtension.cxx.

60 {
61  usingTPCnvForReading( *reinterpret_cast<TopLevelTPCnvBase*>( cnv ) );
62 }

◆ wasClonedFrom()

virtual void AthenaConverterTLPExtension::wasClonedFrom ( AthenaConverterTLPExtension )
inlinevirtual

Remember the original converter that this one was cloned from.

Parameters
converter[IN] the original converter

Definition at line 75 of file AthenaConverterTLPExtension.h.

75 {}

◆ writeObject()

virtual const Token* AthenaConverterTLPExtension::writeObject ( const std::string &  ,
const std::string &   
)
inlinevirtual

Writes the extending persistent object created by this converter Called from the EXTENDED (principal) Athena converter Implemented only in EXTENDING Athena converters.

Parameters
key[in] StoreGet object key (in APR used to determine storage container placement) Retursn Token for the written object

Definition at line 60 of file AthenaConverterTLPExtension.h.

60 { return 0; }

Member Data Documentation

◆ m_clonedExtendingCnvs

std::vector< AthenaConverterTLPExtension* > AthenaConverterTLPExtension::m_clonedExtendingCnvs
protected

list of duplicated converters to delete at the end held in the original converter

Definition at line 151 of file AthenaConverterTLPExtension.h.

◆ m_extCnvMapMap

extCnvMapMap_t AthenaConverterTLPExtension::m_extCnvMapMap
protected

Definition at line 141 of file AthenaConverterTLPExtension.h.

◆ m_extendingConverters

extCnvMap_t AthenaConverterTLPExtension::m_extendingConverters
protected

map of Athena converters extending this one

Definition at line 136 of file AthenaConverterTLPExtension.h.

◆ m_TLCnvForReading

TopLevelTPCnvBase* AthenaConverterTLPExtension::m_TLCnvForReading
protected

additional Top Level TP converter used only for reading tells which converter is used in case of reading old versions (as different versions have different converters) NOT owned byt his class

Definition at line 147 of file AthenaConverterTLPExtension.h.


The documentation for this class was generated from the following files:
TPCnvTokenList_p1
Definition: TPCnvTokenList_p1.h:55
TopLevelTPCnvBase::getConverterID
virtual unsigned short getConverterID()=0
TopLevelTPCnvBase::addTPConvertersForReadingTo
virtual void addTPConvertersForReadingTo(TopLevelTPCnvBase *dest)
copy all extending converters from this top level converter to "dest" top level converter - for readi...
Definition: TopLevelTPCnvBase.cxx:78
TopLevelTPCnvBase::getTokenListVarFrom
virtual TPCnvTokenList_p1 * getTokenListVarFrom(void *persObj)=0
Return the list of tokens to the objects extending the object NOT owned by this converter.
TopLevelTPCnvBase::deleteTLPersObject
virtual void deleteTLPersObject()=0
Delete the persistent object owned by the converter.
skel.it
it
Definition: skel.GENtoEVGEN.py:396
AthenaConverterTLPExtension::m_TLCnvForReading
TopLevelTPCnvBase * m_TLCnvForReading
additional Top Level TP converter used only for reading tells which converter is used in case of read...
Definition: AthenaConverterTLPExtension.h:147
beamspotman.tokens
tokens
Definition: beamspotman.py:1284
dqt_zlumi_pandas.err
err
Definition: dqt_zlumi_pandas.py:182
AthenaConverterTLPExtension::getTopLevelTPCnv
virtual TopLevelTPCnvBase * getTopLevelTPCnv()=0
returns the main top-level TP converter
AthenaConverterTLPExtension
This class is used to add functionality to a standard AthenaConverter.
Definition: AthenaConverterTLPExtension.h:43
AthenaConverterTLPExtension::m_extCnvMapMap
extCnvMapMap_t m_extCnvMapMap
Definition: AthenaConverterTLPExtension.h:141
AthenaConverterTLPExtension::m_extendingConverters
extCnvMap_t m_extendingConverters
map of Athena converters extending this one
Definition: AthenaConverterTLPExtension.h:136
AthenaConverterTLPExtension::m_clonedExtendingCnvs
std::vector< AthenaConverterTLPExtension * > m_clonedExtendingCnvs
list of duplicated converters to delete at the end held in the original converter
Definition: AthenaConverterTLPExtension.h:151
TopLevelTPCnvBase
Base class for top-level TP converters.
Definition: TopLevelTPCnvBase.h:32
AthenaConverterTLPExtension::extCnvMap_t
std::map< unsigned, AthenaConverterTLPExtension * > extCnvMap_t
Definition: AthenaConverterTLPExtension.h:133
AthenaConverterTLPExtension::clone
virtual AthenaConverterTLPExtension * clone()
Clone this Athena Converter.
Definition: AthenaConverterTLPExtension.h:70
AthenaConverterTLPExtension::wasClonedFrom
virtual void wasClonedFrom(AthenaConverterTLPExtension *)
Remember the original converter that this one was cloned from.
Definition: AthenaConverterTLPExtension.h:75
AthenaConverterTLPExtension::getTPCnvID
unsigned short getTPCnvID()
Returns the ID of the main top-level TP converter.
Definition: AthenaConverterTLPExtension.cxx:23
AthenaConverterTLPExtension::deletePersistentObjects
virtual void deletePersistentObjects()
Delete persistent objects held by attached extending converters (used mainly in case of abort)
Definition: AthenaConverterTLPExtension.cxx:148
get_generator_info.error
error
Definition: get_generator_info.py:40
error
Definition: IImpactPoint3dEstimator.h:70
python.compressB64.c
def c
Definition: compressB64.py:93
AthenaConverterTLPExtension::usingTPCnvForReading
void usingTPCnvForReading(TopLevelTPCnvBase &cnv)
Sets top-level TP converter to be used for reading the next object.
Definition: AthenaConverterTLPExtension.cxx:65