ATLAS Offline Software
Loading...
Searching...
No Matches
TopLevelTPCnvBase Class Referenceabstract

Base class for top-level TP converters. More...

#include <TopLevelTPCnvBase.h>

Inheritance diagram for TopLevelTPCnvBase:
Collaboration diagram for TopLevelTPCnvBase:

Public Member Functions

 TopLevelTPCnvBase ()
virtual ~TopLevelTPCnvBase ()
virtual void addTPConverter (ITPConverter *cnv)
 Add a TP converter to this top level converter.
virtual void addTPConverterForReading (ITPConverter *cnv)
 Add a TP converter to this top level converter but only for reading.
virtual void addExtTPConverterForReading (ITPConverter *cnv)
 add extending TP converter to this top level converter - to the list consulted when reading only.
virtual void addTPConvertersTo (TopLevelTPCnvBase *dest)
 copy all extending converters from this top level converter to "dest" top level converter
virtual void addTPConvertersForReadingTo (TopLevelTPCnvBase *dest)
 copy all extending converters from this top level converter to "dest" top level converter - for reading
ITPConverterconverterForType (const std::type_info &info) const
 Find and return a TP converter for a given C++ type info.
ITPConverterconverterForRef (const TPObjRef &ref) const
 Find and return a TP converter for persistent type referenced by ref.
virtual bool hasTLPersObject () const =0
 Returns true if the converter has a persistent object.
virtual void * getTLPersObjectAsVoid ()=0
virtual const void * getTLPersObjectAsVoid () const =0
virtual void createTLPersObject ()=0
 Create persistent object - the converter keeps it.
virtual void deleteTLPersObject ()=0
 Delete the persistent object owned by the converter.
virtual void clearTLPersObject ()=0
 Discard the persistent object.
virtual void setTLPersObject (void *persObj)=0
 Take ownership of the persistent object.
virtual TPCnvTokenList_p1getTokenListVar ()=0
 Return the list of tokens to the objects extending the object owned by this converter.
virtual TPCnvTokenList_p1getTokenListVarFrom (void *persObj)=0
 Return the list of tokens to the objects extending the object NOT owned by this converter.
virtual unsigned short getConverterID ()=0

Protected Types

typedef std::map< unsigned, ITPConverter * > convIdMap_t

Protected Member Functions

void rememberConverter (TopLevelTPCnvBase *cnv)
 Remember that elemental TP converters from the given top-level converter are already registered.
bool hasConvertersFrom (TopLevelTPCnvBase *cnv)
 Check if TP converters from a given top-level converter were already registered in this converter.

Protected Attributes

convIdMap_t m_convIdMap
 Map of elemental TP converters indexed by their ID - used for reading.
TPConverterTypeMap< ITPConverterm_converters
 Map of elemental TP converters indexed by transient typeid - used for writing.
std::set< TopLevelTPCnvBase * > m_registeredTLConverters
 Set top-level converters from which elemental TP converters were registered.
unsigned m_typeIDCount
 Counter used to create typed IDs used in the transient Ref.

Private Member Functions

virtual void addTPConverterForWriting (ITPConverter *cnv)
 add TP converter to the list of converters consulted when writing - internal method.

Detailed Description

Base class for top-level TP converters.

Base (not templated) class for all top-level TP converters. Provides:

  • handling of elemental TP converters
  • typeless interface to access the persistent object being converted by this top-level converter

Definition at line 31 of file TopLevelTPCnvBase.h.

Member Typedef Documentation

◆ convIdMap_t

typedef std::map<unsigned, ITPConverter*> TopLevelTPCnvBase::convIdMap_t
protected

Definition at line 174 of file TopLevelTPCnvBase.h.

Constructor & Destructor Documentation

◆ TopLevelTPCnvBase()

TopLevelTPCnvBase::TopLevelTPCnvBase ( )
inline

Definition at line 34 of file TopLevelTPCnvBase.h.

34: m_typeIDCount(0) { }
unsigned m_typeIDCount
Counter used to create typed IDs used in the transient Ref.

◆ ~TopLevelTPCnvBase()

virtual TopLevelTPCnvBase::~TopLevelTPCnvBase ( )
inlinevirtual

Definition at line 36 of file TopLevelTPCnvBase.h.

36{ }

Member Function Documentation

◆ addExtTPConverterForReading()

void TopLevelTPCnvBase::addExtTPConverterForReading ( ITPConverter * cnv)
virtual

add extending TP converter to this top level converter - to the list consulted when reading only.

Parameters
cnv[IN] the TP converter to be added

Definition at line 47 of file TopLevelTPCnvBase.cxx.

48{
49 // for reading, converters are selected based on our own typeID value
50 // which comes from the Ref
51 // Ref contains top level converter ID + local type ID
52 m_convIdMap[ converter->typeID().value() ] = converter;
53
54// std::cout << " **addExtTPConverterForReading - adding converter for " << converter->transientTInfo().name() << " CnvID=" << converter->typeID().value() << std::endl;
55 converter->setRuntimeTopConverter( this );
56}
convIdMap_t m_convIdMap
Map of elemental TP converters indexed by their ID - used for reading.

◆ addTPConverter()

void TopLevelTPCnvBase::addTPConverter ( ITPConverter * cnv)
virtual

Add a TP converter to this top level converter.

Parameters
cnv[IN] the TP converter to be added

Definition at line 11 of file TopLevelTPCnvBase.cxx.

12{
13 addTPConverterForWriting( converter );
14 addTPConverterForReading( converter );
15}
virtual void addTPConverterForReading(ITPConverter *cnv)
Add a TP converter to this top level converter but only for reading.
virtual void addTPConverterForWriting(ITPConverter *cnv)
add TP converter to the list of converters consulted when writing - internal method.

◆ addTPConverterForReading()

void TopLevelTPCnvBase::addTPConverterForReading ( ITPConverter * cnv)
virtual

Add a TP converter to this top level converter but only for reading.

Old converters that read schema evolved objects should be added only for reading.

Parameters
cnv[IN] the TP converter to be added

Definition at line 19 of file TopLevelTPCnvBase.cxx.

20{
21 // for reading, converters are selected based on their typeID value
22 // which comes from the Ref
23 // Ref contains top level converter ID + local type ID
24 TPObjRef::typeID_t full_typeID( getConverterID(), ++m_typeIDCount );
25 m_convIdMap[ full_typeID.value() ] = converter;
26
27// std::cout << " **addTPConverter - adding converter for " << converter->transientTInfo().name() << " CnvID=" << full_typeID.value() << std::endl;
28 converter->setTopConverter( this, full_typeID );
29}
virtual unsigned short getConverterID()=0

◆ addTPConverterForWriting()

void TopLevelTPCnvBase::addTPConverterForWriting ( ITPConverter * cnv)
privatevirtual

add TP converter to the list of converters consulted when writing - internal method.

Parameters
cnv[IN] the TP converter to be added

Definition at line 33 of file TopLevelTPCnvBase.cxx.

34{
35 // add converter to the map keyed by type_info
36 // this map is used to find a converter when writing
37 const std::type_info &info( converter->transientTInfo() );
38 if( m_converters.findConverter( info ) ) {
39 // adding a second converter for the same type will mess up things
40 const std::string error("Duplicate TP converter for class ");
41 throw std::runtime_error( error + info.name() );
42 }
43 m_converters.addConverter( converter, info );
44}
TPConverterTypeMap< ITPConverter > m_converters
Map of elemental TP converters indexed by transient typeid - used for writing.

◆ addTPConvertersForReadingTo()

void TopLevelTPCnvBase::addTPConvertersForReadingTo ( TopLevelTPCnvBase * dest)
virtual

copy all extending converters from this top level converter to "dest" top level converter - for reading

Parameters
dest[IN] destination converter which will receive all elemental TP converters that this one has

Definition at line 78 of file TopLevelTPCnvBase.cxx.

79{
80 // check if we have done this already, and if so then exit
81 if( cnv->hasConvertersFrom( this ) ) {
82 return;
83 }
84 // copy all TP converters to another topLevel conveter
85 for( convIdMap_t::const_iterator itr = m_convIdMap.begin();
86 itr != m_convIdMap.end(); ++itr ) {
87 cnv->addExtTPConverterForReading( itr->second );
88 }
89 // prevent attempts to add the same converters again
90 cnv->rememberConverter( this );
91}

◆ addTPConvertersTo()

void TopLevelTPCnvBase::addTPConvertersTo ( TopLevelTPCnvBase * dest)
virtual

copy all extending converters from this top level converter to "dest" top level converter

copy all TP converters to another topLevel conveter

Parameters
dest[IN] destination converter which will receive all elemental TP converters that this one has

Definition at line 60 of file TopLevelTPCnvBase.cxx.

61{
62 // loop over all registered converters
63 for( convIdMap_t::const_iterator itr = m_convIdMap.begin();
64 itr != m_convIdMap.end(); ++itr ) {
65 // check if the converter is in the list of R/W converters
66 if( m_converters.findConverter( itr->second->transientTInfo() ) == itr->second ) {
67 // this is a R/W converter, add it for writing too
68 cnv->addTPConverterForWriting( itr->second );
69 }
70 // add the convterter for reading
71 cnv->addExtTPConverterForReading( itr->second );
72 }
73 // prevent adding of the same converter again
74 cnv->rememberConverter( this );
75}

◆ clearTLPersObject()

virtual void TopLevelTPCnvBase::clearTLPersObject ( )
pure virtual

Discard the persistent object.

Implemented in TopLevelTPCnvBaseP< TL_PERS >.

◆ converterForRef()

ITPConverter * TopLevelTPCnvBase::converterForRef ( const TPObjRef & ref) const
inline

Find and return a TP converter for persistent type referenced by ref.

Parameters
ref[IN] TP reference of a persistent object
Returns
ITPConverter* pointer to the TP converter for ref

Definition at line 89 of file TopLevelTPCnvBase.h.

89 {
90 convIdMap_t::const_iterator iter = m_convIdMap.find( ref.typeID() );
91 return (iter == m_convIdMap.end())?
92 0 : iter->second;
93 }
const boost::regex ref(r_ef)

◆ converterForType()

ITPConverter * TopLevelTPCnvBase::converterForType ( const std::type_info & info) const
inline

Find and return a TP converter for a given C++ type info.

Parameters
info[IN] C++ type info reference to the transient type
Returns
ITPConverter* pointer to the TP converter for type info

Definition at line 80 of file TopLevelTPCnvBase.h.

80 {
81 return m_converters.findConverter( info );
82 }

◆ createTLPersObject()

virtual void TopLevelTPCnvBase::createTLPersObject ( )
pure virtual

Create persistent object - the converter keeps it.

Implemented in TopLevelTPCnvBaseP< TL_PERS >.

◆ deleteTLPersObject()

virtual void TopLevelTPCnvBase::deleteTLPersObject ( )
pure virtual

Delete the persistent object owned by the converter.

Implemented in TopLevelTPCnvBaseP< TL_PERS >.

◆ getConverterID()

◆ getTLPersObjectAsVoid() [1/2]

virtual const void * TopLevelTPCnvBase::getTLPersObjectAsVoid ( ) const
pure virtual
Returns
pointer to the persistent object owned by this converter as void*

Implemented in TopLevelTPCnvBaseP< TL_PERS >.

◆ getTLPersObjectAsVoid() [2/2]

virtual void * TopLevelTPCnvBase::getTLPersObjectAsVoid ( )
pure virtual
Returns
pointer to the persistent object owned by this converter as void*

Implemented in TopLevelTPCnvBaseP< TL_PERS >.

◆ getTokenListVar()

◆ getTokenListVarFrom()

virtual TPCnvTokenList_p1 * TopLevelTPCnvBase::getTokenListVarFrom ( void * persObj)
pure virtual

Return the list of tokens to the objects extending the object NOT owned by this converter.

Parameters
persObj[IN] persistent object from which contains list of tokens. Passes as void* - if the type is wrong, it may crash
Returns
pointer to the token list from persObj

Implemented in TopLevelTPCnvBaseP< TL_PERS >.

◆ hasConvertersFrom()

bool TopLevelTPCnvBase::hasConvertersFrom ( TopLevelTPCnvBase * cnv)
inlineprotected

Check if TP converters from a given top-level converter were already registered in this converter.

Parameters
cnv[IN] top-level converter to check
Returns
true if TP converters from cnv were already registered

Definition at line 166 of file TopLevelTPCnvBase.h.

167 {
168 return m_registeredTLConverters.find(cnv) != m_registeredTLConverters.end();
169 }
std::set< TopLevelTPCnvBase * > m_registeredTLConverters
Set top-level converters from which elemental TP converters were registered.

◆ hasTLPersObject()

virtual bool TopLevelTPCnvBase::hasTLPersObject ( ) const
pure virtual

Returns true if the converter has a persistent object.

Implemented in TopLevelTPCnvBaseP< TL_PERS >.

◆ rememberConverter()

void TopLevelTPCnvBase::rememberConverter ( TopLevelTPCnvBase * cnv)
inlineprotected

Remember that elemental TP converters from the given top-level converter are already registered.

Parameters
cnv[IN] top-level TP converter - source of the elemental TP converters

Definition at line 156 of file TopLevelTPCnvBase.h.

157 {
158 m_registeredTLConverters.insert(cnv);
159 }

◆ setTLPersObject()

virtual void TopLevelTPCnvBase::setTLPersObject ( void * persObj)
pure virtual

Take ownership of the persistent object.

Also initialize all elemental TP converters to use that object.

Parameters
persObj[IN] the persistent object passed as void*

Implemented in TopLevelTPCnvBaseP< TL_PERS >.

Member Data Documentation

◆ m_converters

TPConverterTypeMap< ITPConverter > TopLevelTPCnvBase::m_converters
protected

Map of elemental TP converters indexed by transient typeid - used for writing.

Definition at line 180 of file TopLevelTPCnvBase.h.

◆ m_convIdMap

convIdMap_t TopLevelTPCnvBase::m_convIdMap
protected

Map of elemental TP converters indexed by their ID - used for reading.

Definition at line 177 of file TopLevelTPCnvBase.h.

◆ m_registeredTLConverters

std::set<TopLevelTPCnvBase*> TopLevelTPCnvBase::m_registeredTLConverters
protected

Set top-level converters from which elemental TP converters were registered.

Definition at line 184 of file TopLevelTPCnvBase.h.

◆ m_typeIDCount

unsigned TopLevelTPCnvBase::m_typeIDCount
protected

Counter used to create typed IDs used in the transient Ref.

Definition at line 187 of file TopLevelTPCnvBase.h.


The documentation for this class was generated from the following files: