|
ATLAS Offline Software
|
Go to the documentation of this file.
8 #define TPCONVERTER_H 1
22 #include "GaudiKernel/MsgStream.h"
35 template<
class TRANS >
56 template <
class CNV >
60 cnv =
dynamic_cast< CNV*
>(
c );
72 template <
class CNV >
76 cnv =
dynamic_cast<CNV*
>(
c);
95 template <
class CNV >
98 if( !*cnv || (*cnv)->wasUsedForReading() ) {
102 (*cnv)->clearReadingFlag();
105 return (**cnv).virt_toPersistent(transObj,
log);
118 template <
class CNV >
122 if( !cnv ) cnv = &temp_cnv_p;
123 if( !*cnv || (*cnv)->wasUsedForReading() ) {
127 (*cnv)->clearReadingFlag();
129 return (**cnv).virt_toPersistent(transObj,
log);
144 template <
class CNV,
class TRANS_T >
146 if(
ref.isNull() )
return;
148 if( !cnv ) cnv = &temp_cnv_p;
150 if( !*cnv || (*cnv)->typeID().value() !=
ref.typeID() ) {
154 (*cnv)->setReadingFlag();
156 (**cnv).pstoreToTrans(
ref.index(), trans,
log );
170 template <
class CNV >
171 typename CNV::Trans_t*
173 if(
ref.isNull() )
return 0;
175 if( !cnv ) cnv = &temp_cnv_p;
177 if( !*cnv || (*cnv)->typeID().value() !=
ref.typeID() ) {
180 if( !*cnv )
return 0;
181 (*cnv)->setReadingFlag();
183 return (**cnv).virt_createTransFromPStore(
ref.index(),
log );
260 const std::string&
key,
279 const std::string&
key,
280 MsgStream &
log ) = 0;
329 template<
class TRANS_BASE,
class TRANS,
class PERS >
405 reinterpret_cast<TRANS*
> (trans),
414 transToPers (
reinterpret_cast<const TRANS*
> (trans),
415 reinterpret_cast<PERS*
> (pers),
422 const std::string&
key,
426 reinterpret_cast<TRANS*
> (trans),
434 const std::string&
key,
438 reinterpret_cast<PERS*
> (pers),
462 const std::string&
key,
474 const std::string&
key,
495 assert (index < m_pStorage->
size());
496 TRANS* trans_der =
dynamic_cast<TRANS*
>(trans);
497 if (!trans_der) std::abort();
506 const TRANS* trans_der =
dynamic_cast<const TRANS*
>(trans);
507 if (!trans_der) std::abort();
516 const std::string&
key,
519 const TRANS* trans_der =
dynamic_cast<const TRANS*
>(trans);
520 if (!trans_der) std::abort();
529 throw std::runtime_error(
530 std::string(
"virt_createTransFromPStore() mothod not supported in TP converter for an abstract class: ")
531 +
typeid(*this).name() );
540 throw std::runtime_error(
541 std::string(
"virt_createTransFromPStore() method not supported in TP converter for an abstract class: ")
542 +
typeid(*this).name() );
597 template<
class TRANS_BASE,
class TRANS,
class PERS >
615 MsgStream &
log)
const = 0;
627 MsgStream &
log)
const = 0;
633 MsgStream &
log)
override final
641 MsgStream &
log)
override final
671 template<
class TRANS_BASE,
class TRANS,
class PERS >
719 const std::string&
key,
735 template<
class TRANS,
class PERS >
753 const std::string&
key,
773 template<
class TRANS,
class PERS >
791 MsgStream &
log)
const = 0;
803 MsgStream &
log)
const = 0;
809 MsgStream &
log)
override final
817 MsgStream &
log)
override final
832 template<
class TRANS,
class PERS >
854 const std::string&
key,
855 MsgStream &
log)
const = 0;
868 const std::string&
key,
869 MsgStream &
log)
const = 0;
875 const std::string&
key,
876 MsgStream &
log)
override final
884 const std::string&
key,
885 MsgStream &
log)
override final
894 MsgStream& )
const override final
896 throw std::runtime_error (
"persToTrans called where persToTransWithKey required.");
902 MsgStream& )
const override final
904 throw std::runtime_error (
"transToPers called where transToPersWithKey required.");
918 template<
class TRANS,
class PERS,
class CONV>
931 transVect->reserve( persVect->size() );
933 for(
typename PERS::const_iterator
934 it = persVect->begin(),
935 iEnd = persVect->end();
950 persVect->reserve( transVect->size() );
952 for(
typename TRANS::const_iterator
953 it = transVect->begin(),
954 iEnd = transVect->end();
978 template<
class TRANS,
class PERS,
class CONV>
995 transVect->reserve( persVect->size() );
998 for(
typename PERS::const_iterator
999 it = persVect->begin(),
1000 iEnd = persVect->end();
1001 it != iEnd; ++
it ) {
1017 persVect->reserve( transVect->size() );
1019 CONV* cnv =
nullptr;
1020 for(
typename TRANS::const_iterator
1021 it = transVect->begin(),
1022 iEnd = transVect->end();
1023 it != iEnd; ++
it ) {
1041 template<
class TRANS,
class PERS,
class CONV>
1059 const std::string& ,
1060 MsgStream &
log)
const override
1063 transVect->reserve( persVect->size() );
1065 CONV* cnv =
nullptr;
1066 for(
typename PERS::const_iterator
1067 it = persVect->begin(),
1068 iEnd = persVect->end();
1069 it != iEnd; ++
it ) {
1085 const std::string&
key,
1086 MsgStream &
log)
const override
1090 persVect->reserve( transVect->size() );
1092 CONV* cnv =
nullptr;
1094 for(
typename TRANS::const_iterator
1095 it = transVect->begin(),
1096 iEnd = transVect->end();
1097 it != iEnd; ++
it, ++ipos )
1099 if (!dec || !dec->
thinned (ipos)) {
1117 template<
class TRANS,
class PERS,
class CONV>
1124 persVect->reserve( transVect->size() );
1126 for(
typename TRANS::const_iterator
1127 it = transVect->begin(),
1128 iEnd = transVect->end();
1129 it != iEnd; ++
it ) {
1145 template<
class TRANS,
class PERS,
class CONV>
1156 persVect->reserve( transVect->size() );
1158 for(
typename TRANS::const_iterator
1159 it = transVect->begin(),
1160 iEnd = transVect->end();
1161 it != iEnd; ++
it ) {
1173 template<
class TRANS,
class PERS,
class CONV>
1181 transVect->reserve( persVect->size() );
1184 typename PERS::const_iterator
pi = persVect->begin(), iEnd = persVect->end();
1185 for( ;
pi != iEnd; ++
pi, ++ti ) {
1193 persVect->reserve( transVect->size() );
1195 for(
typename TRANS::const_iterator
1196 it = transVect->begin(), iEnd = transVect->end();
1197 it != iEnd; ++
it ) {
1215 template<
class TRANS,
class PERS,
class CONV>
1233 template<
class TRANS,
class PERS,
class CONV>
1255 template<
class TRANS,
class PERS,
class CONV>
1270 template<
class TRANS,
class PERS,
class CONV>
1290 template<
class TRANS,
class PERS,
class CONV>
1306 template<
class TRANS,
class PERS,
class CONV>
1317 MsgStream &
log)
const override;
1322 MsgStream &
log)
const override;
1334 template<
class TRANS,
class PERS,
class CONV>
1359 template<
class TRANS,
class PERS,
class CONV>
JetConstituentVector::iterator iterator
virtual void transToPers(const TRANS *transObj, PERS *persObj, MsgStream &log) override final
Convert transient representation to persistent one.
virtual void transToPersWithKey(const TRANS *transObj, PERS *persObj, const std::string &key, MsgStream &log) const =0
Convert transient representation to persistent one.
ITPConverter * converterForType(const std::type_info &info) const
Find and return a TP converter for a given C++ type info.
std::vector< PERS > * m_pStorage
the address of the storage vector for persistent representations
virtual TPObjRef virt_toPersistentWithKey(const TRANS_BASE *trans, const std::string &key, MsgStream &log)
Internal interface method that is used to invoke the real conversion method (toPersistent_impl) in th...
virtual TRANS * virt_createTransFromPStore(unsigned, MsgStream &)
This method implements a pure virtual base class method, but should never be called,...
TopLevelTPCnvBase * m_topConverter
top level converter that owns this elemental TP converter it also holds the storage object
virtual void transToPers(const TRANS *transCont, PERS *persCont, MsgStream &log)
transToPers
virtual void persToTrans(const PERS *persObj, TRANS *transObj, MsgStream &log) override final
Convert persistent representation to transient one.
virtual TRANS * virt_createTransFromPStoreWithKey(unsigned index, const std::string &key, MsgStream &log)
Internal interface method that is used to invoke the real conversion method (createTransient)
virtual TPObjRef virt_toPersistent(const TRANS_BASE *trans, MsgStream &log)
Internal interface method that is used to invoke the real conversion method (toPersistent_impl) in th...
void setPStorage(std::vector< PERS > *storage)
Tell this converter which storage vector it should use to store or retrieve persistent representation...
TPObjRef toPersistentWithKey_impl(const TRANS *trans, const std::string &key, MsgStream &log)
Convert transient object to persistent representation.
CONV m_elementCnv
the TP converter used for vector elements
unsigned value() const
Returns the type ID as an integer.
virtual void transToPers(const TRANS *transObj, PERS *persObj, MsgStream &log) const =0
Convert transient representation to persistent one.
Hold thinning decisions for one container.
virtual const TPObjRef::typeID_t & typeID() const
Return TP typeID for persistent objects produced by this converter.
virtual TRANS * createTransient(const PERS *persObj, MsgStream &log)
Create transient representation of a persistent object.
virtual void persToTrans(const PERS *persVect, TRANS *transVect, MsgStream &log)
Converts vector of PERS::value_type objects to vector of TRANS::value_type objects,...
virtual void persToTrans(const PERS *, TRANS *, MsgStream &) const override final
Convert persistent representation to transient one.
virtual void persToTrans(const PERS *persVect, TRANS *transVect, MsgStream &log)
Converts vector of PERS::value_type objects to vector of TRANS::value_type objects,...
TPCnvIDContFromIdentifier()
bool thinned(size_t ndx) const
Return true if element ndx should be thinned.
ITPConverter * converterForRef(const TPObjRef &ref) const
Find and return a TP converter for persistent type referenced by ref.
virtual TRANS * virt_createTransFromPStore(unsigned index, MsgStream &log)
Internal interface method that is used to invoke the real conversion method (createTransient)
virtual void transToPers(const TRANS *transCont, PERS *persCont, MsgStream &log)
transToPers
virtual TRANS * createTransientWithKey(const PERS *persObj, const std::string &key, MsgStream &log)
Create transient representation of a persistent object, with SG key.
Hold thinning decisions for one container.
virtual void transToPersWithKeyUntyped(const void *trans, void *pers, const std::string &key, MsgStream &log)
Convert transient object representation to persistent.
virtual void transToPers(const TRANS *transObj, PERS *persObj, MsgStream &log) const =0
Convert transient representation to persistent one.
virtual PERS * createPersistent(const TRANS *transObj, MsgStream &log)
Create persistent representation of a transient object.
bool m_ignoreRecursion
if true, do not throw errors in case of recursion.
virtual const std::type_info & persistentTInfo() const
return C++ type id of the persistent class this converter is for
virtual PERS * createPersistentWithKey(const TRANS *transObj, const std::string &key, MsgStream &log)
Create persistent representation of a transient object, with SG key.
virtual TopLevelTPCnvBase * topConverter()
return the top-level converter for this elemental TP converter
virtual void pstoreToTrans(unsigned index, TRANS_BASE *trans, MsgStream &log)
Convert persistent representation stored in the storage vector of the top-level object to transient.
void fillTransFromPStore(CNV **cnv, const TPObjRef &ref, TRANS_T *trans, MsgStream &log) const
Convert persistent object, stored in the the top-level persistent object and referenced by the TP Ref...
virtual void persToTransWithKey(const PERS *persObj, TRANS *transObj, const std::string &key, MsgStream &log) const =0
Convert persistent representation to transient one.
virtual void transToPers(const TRANS *transVect, PERS *persVect, MsgStream &log) const override
Converts vector of TRANS::value_type objects to vector of PERS::value_type objects,...
const std::type_info & transBaseTInfo() const
return C++ type id of the common base transient type for all converters for a group of polymorphic ty...
virtual void transToPers(const TRANS *transObj, PERS *persObj, MsgStream &log)=0
Convert transient representation to persistent one.
bool m_wasUsedForReading
flag set when using this converter for reading triggers search for a new converter before writing,...
virtual void persToTrans(const PERS *persObj, TRANS *transObj, MsgStream &log) override final
Convert persistent representation to transient one.
a link optimized in size for a GenParticle in a McEventCollection
virtual void transToPers(const TRANS *, PERS *, MsgStream &) const override final
Convert transient representation to persistent one.
virtual void transToPers(const TRANS *transVect, PERS *persVect, MsgStream &log)
Converts vector of TRANS::value_type objects to vector of PERS::value_type objects,...
CNV * converterForType(CNV *cnv, const std::type_info &t_info, MsgStream &log) const
Find converter for a given C++ type ID, that is or ihnerits from CNV type.
virtual TPObjRef virt_toPersistentWithKey(const TRANS *trans, const std::string &key, MsgStream &log)
Internal interface method that is used to invoke the real conversion method (toPersistent_impl) in th...
virtual void transToPers(const TRANS *transVect, PERS *persVect, MsgStream &log)
Converts vector of TRANS::value_type objects to vector of PERS::value_type objects,...
ITPConverterFor< TRANS > PolyCnvBase_t
CONV * m_elementCnv
pointer to the TP converter used for vector elements
TPObjRef::typeID_t m_pStorageTID
TP Ref typeID for the persistent objects this converter is creating.
virtual void setRuntimeTopConverter(TopLevelTPCnvBase *topConverter)
Set runtime top-level converter - usually it is the owning TL converter, but in case of extended obje...
virtual void reservePStorage(size_t size)
Reserve 'size' elements for persistent storage.
virtual void persToTrans(const PERS *persVect, TRANS *transVect, MsgStream &log) const override
Converts vector of PERS::value_type objects to vector of TRANS::value_type objects,...
virtual void transToPers(const TRANS *transVect, PERS *persVect, MsgStream &log)
Converts vector of TRANS::value_type objects to vector of PERS::value_type objects,...
Helpers to retrieve the current thinning cache from the event context.
virtual void persToTransWithKey(const PERS *persObj, TRANS *transObj, const std::string &, MsgStream &log)
Convert persistent representation to transient one.
virtual void persToTrans(const PERS *persVect, TRANS *transVect, MsgStream &log)
Converts vector of PERS::value_type objects to vector of TRANS::value_type objects,...
virtual void transToPers(const TRANS *transVect, PERS *persVect, MsgStream &log)
Converts vector of TRANS::value_type objects to vector of PERS::value_type objects,...
virtual PERS * createPersistentConst(const TRANS *transObj, MsgStream &log) const
virtual void pstoreToTrans(unsigned index, TRANS *trans, MsgStream &log)
Convert persistent representation stored in the storage vector of the top-level object to transient.
CONV m_elementCnv
the TP converter used for vector elements
TopLevelTPCnvBase * m_topConverterRuntime
top level converter "owning" this TP converter at runtime (different from m_topConverter in case the ...
virtual void transToPers(const TRANS *transVect, PERS *persVect, MsgStream &log)
Converts vector of TRANS::value_type objects to vector of PERS::value_type objects,...
virtual void transToPersUntyped(const void *trans, void *pers, MsgStream &log)
Convert transient object representation to persistent.
CNV * converterForRef(CNV *cnv, const TPObjRef &ref, MsgStream &log) const
Find converter for a TP type ID (passed in a TP Ref), that is or ihnerits from CNV type.
TPObjRef toPersistent(CNV **cnv, const typename CNV::TransBase_t *transObj, MsgStream &log) const
Persistify an object and store the persistent represenation in the storage vector of the top-level pe...
TPObjRef baseToPersistent(CNV **cnv, const typename CNV::Trans_t *transObj, MsgStream &log) const
Persistify bass class of a given object and store the persistent represenation in the storage vector ...
const SG::ThinningDecisionBase * getThinningDecision(const EventContext &ctx, const std::string &key)
Retrieve the current thinning decision for key.
virtual void persToTrans(const PERS *persVect, TRANS *transVect, MsgStream &log)
Converts vector of PERS::value_type objects to vector of TRANS::value_type objects,...
virtual void persToTrans(const PERS *persCont, TRANS *transCont, MsgStream &log)
persToTrans
virtual void persToTrans(const PERS *persObj, TRANS *transObj, MsgStream &log) const =0
Convert persistent representation to transient one.
virtual const TopLevelTPCnvBase * topConverter() const
return the top-level converter for this elemental TP converter
Base class for top-level TP converters.
virtual void setTopConverter(TopLevelTPCnvBase *topConverter, const TPObjRef::typeID_t &TPtypeID)
Set which top-level converter owns this elemental converter, and what TPtypeID was assigned to the pe...
RpcSectorLogicContainer_p1 PERS
virtual void pstoreToTrans(unsigned index, TransBase_t *transObj, MsgStream &log)=0
Internal interface method that is used to invoke the real conversion method (persToTrans) in the deri...
virtual ~ITPConverterFor()=default
virtual void persToTrans(const PERS *persVect, TRANS *transVect, MsgStream &log)
Converts vector of PERS::value_type objects to vector of TRANS::value_type objects,...
virtual void transToPersWithKey(const TRANS *transObj, PERS *persObj, const std::string &, MsgStream &log)
Convert transient representation to persistent one.
unsigned typeIDvalue() const
inlined non-virtual version to get the typeID value fast
virtual void persToTrans(const PERS *persVect, TRANS *transVect, MsgStream &log)
Converts vector of PERS::value_type objects to vector of TRANS::value_type objects,...
virtual void initPrivateConverters(TopLevelTPCnvBase *)
bool m_recursive
if true, work in recursion-safe way (slower)
virtual void transToPers(const TRANS *transVect, PERS *persVect, MsgStream &log)
Converts vector of TRANS::value_type objects to vector of PERS::value_type objects,...
virtual void persToTransWithKey(const PERS *persVect, TRANS *transVect, const std::string &, MsgStream &log) const override
Converts vector of PERS::value_type objects to vector of TRANS::value_type objects,...
virtual TRANS * virt_createTransFromPStoreWithKey(unsigned index, const std::string &key, MsgStream &log)=0
Internal interface method that is used to invoke the real conversion method (createTransient) in the ...
virtual TRANS * virt_createTransFromPStoreWithKey(unsigned, const std::string &, MsgStream &)
This method implements a pure virtual base class method, but should never be called,...
virtual void transToPers(const TRANS *transVect, PERS *persVect, MsgStream &log) const override
Converts vector of TRANS::value_type objects to vector of PERS::value_type objects,...
virtual void transToPersWithKey(const TRANS *transVect, PERS *persVect, const std::string &key, MsgStream &log) const override
Converts vector of TRANS::value_type objects to vector of PERS::value_type objects,...
virtual void transToPers(const TRANS *transObj, PERS *persObj, MsgStream &log) override final
Convert transient representation to persistent one.
virtual void transToPersWithKey(const TRANS *transObj, PERS *persObj, const std::string &key, MsgStream &log) override final
Convert transient representation to persistent one.
unsigned m_pStorageTIDvalue
m_pStorageTID converted to integer value
virtual TPObjRef virt_toPersistent(const TRANS *trans, MsgStream &log)
Internal interface method that is used to invoke the real conversion method (toPersistent_impl) in th...
virtual ~TPConverterBase()=default
const boost::regex ref(r_ef)
Const version of TPCnvStdVector.
virtual void persToTrans(const PERS *persCont, TRANS *transCont, MsgStream &log)
persToTrans
virtual void persToTrans(const PERS *persObj, TRANS *transObj, MsgStream &log)=0
Convert persistent representation to transient one.
virtual void persToTransWithKey(const PERS *persObj, TRANS *transObj, const std::string &key, MsgStream &log) override final
Convert persistent representation to transient one.
Defines the base class for top-level TP converters.
virtual void transToPers(const TRANS *transVect, PERS *persVect, MsgStream &log) const override
Converts vector of TRANS::value_type objects to vector of PERS::value_type objects,...
CONV * m_elementCnv
pointer to the TP converter used for vector elements
TRANS::IDENTIFIABLE COLLECTION_t
virtual void persToTrans(const PERS *persVect, TRANS *transVect, MsgStream &log) const override
Converts vector of PERS::value_type objects to vector of TRANS::value_type objects,...
virtual void transToPers(const TRANS *transVect, PERS *persVect, MsgStream &log) const
Converts vector of TRANS::value_type objects to vector of PERS::value_type objects,...
void setRecursive(bool flag=true)
Tell the converter if it should work in recursive mode slower but it can safely handle recursion.
virtual void persToTransUntyped(const void *pers, void *trans, MsgStream &log)
Convert persistent object representation to transient.
virtual ~TPPolyCnvBase()=default
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
unsigned typeID() const
returns the type ID (as integer) of the referenced object
CONV m_elementCnv
the TP converter used for vector elements
virtual const std::type_info & transientTInfo() const
return C++ type id of the transient class this converter is for
virtual TRANS * virt_createTransFromPStore(unsigned index, MsgStream &log)=0
Internal interface method that is used to invoke the real conversion method (createTransient) in the ...
virtual TPObjRef virt_toPersistent(const TransBase_t *trans, MsgStream &log)=0
Internal interface method that is used to invoke the real conversion method (toPersistent_impl) in th...
virtual void persToTrans(const PERS *persVect, TRANS *transVect, MsgStream &log) const override
Converts vector of PERS::value_type objects to vector of TRANS::value_type objects,...
void ignoreRecursion(bool flag=false)
Tell the converter to ignore recursion (do not throw errors) even when recurion is detected.
virtual void persToTransWithKeyUntyped(const void *pers, void *trans, const std::string &key, MsgStream &log)
Convert persistent object representation to transient.
virtual const std::type_info & transientTInfo() const
return C++ type id of the transient class this converter is for
virtual void transToPers(const TRANS *transVect, PERS *persVect, MsgStream &log)
Converts vector of TRANS::value_type objects to vector of PERS::value_type objects,...
virtual ~TPAbstractPolyCnvBase()=default
int m_curRecLevel
count recursive invocations, to detect recursion
virtual TRANS * createTransientConst(const PERS *persObj, MsgStream &log) const
virtual TPObjRef virt_toPersistentWithKey(const TransBase_t *trans, const std::string &key, MsgStream &log)=0
Internal interface method that is used to invoke the real conversion method (toPersistent_impl) in th...
CNV::Trans_t * createTransFromPStore(CNV **cnv, const TPObjRef &ref, MsgStream &log) const
Create transient representation of a persistent object, stored in the the top-level persistent object...
virtual void persToTrans(const PERS *persObj, TRANS *transObj, MsgStream &log) const =0
Convert persistent representation to transient one.
TRANS::IDENTIFIABLE COLLECTION_t