diff --git a/Tracking/TrkDetDescr/TrkDetDescrAthenaPool/cmt/requirements b/Tracking/TrkDetDescr/TrkDetDescrAthenaPool/cmt/requirements index c865301202201f6061896020ec934c80f9d6e7c8..670900f9ddf0e7c982a46afe1396849d50741538 100755 --- a/Tracking/TrkDetDescr/TrkDetDescrAthenaPool/cmt/requirements +++ b/Tracking/TrkDetDescr/TrkDetDescrAthenaPool/cmt/requirements @@ -18,7 +18,7 @@ use AthenaPoolUtilities AthenaPoolUtilities-* Database/AthenaPOOL #use AthenaPoolCnvSvc AthenaPoolCnvSvc-00-* Database/AthenaPOOL -apply_pattern poolcnv files="-s=$(TrkGeometry_root)/TrkGeometry MaterialStepCollection.h LayerMaterialCollection.h LayerMaterialMap.h" +apply_pattern poolcnv files="-s=$(TrkGeometry_root)/TrkGeometry MaterialStepCollection.h LayerMaterialMap.h ElementTable.h" private #macro cppdebugflags '$(cppdebugflags_s)' diff --git a/Tracking/TrkDetDescr/TrkDetDescrAthenaPool/src/ElementTableCnv.cxx b/Tracking/TrkDetDescr/TrkDetDescrAthenaPool/src/ElementTableCnv.cxx new file mode 100644 index 0000000000000000000000000000000000000000..ba83fd50d79a851b760b2092f866cb2640f00488 --- /dev/null +++ b/Tracking/TrkDetDescr/TrkDetDescrAthenaPool/src/ElementTableCnv.cxx @@ -0,0 +1,84 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +////////////////////////////////////////////////////////////////// +// ElementTableCnv.cxx, (c) ATLAS Detector software +/////////////////////////////////////////////////////////////////// + +#include "ElementTableCnv.h" +#include "GaudiKernel/MsgStream.h" + + +//----------------------------------------------------------------------------- +// Constructor +//----------------------------------------------------------------------------- + +ElementTableCnv::ElementTableCnv( ISvcLocator *svcloc ) : + ElementTableCnvBase(svcloc), + m_msgSvc( msgSvc() ), + m_log( m_msgSvc, "ElementTableCnv" ) + {} + +//----------------------------------------------------------------------------- +// Destructor +//----------------------------------------------------------------------------- +ElementTableCnv::~ElementTableCnv() +{} + +//----------------------------------------------------------------------------- +// Initializer +//----------------------------------------------------------------------------- +StatusCode ElementTableCnv::initialize() +{ + if (ElementTableCnvBase::initialize().isFailure() ) + { + m_log << MSG::FATAL << "Could not initialize ElementTableCnvBase" << endreq; + return StatusCode::FAILURE; + } + + return StatusCode::SUCCESS; + +} + +ElementTable_PERS* ElementTableCnv::createPersistent(Trk::ElementTable *etTrans) { + + // Message stream handling + m_log.setLevel( m_msgSvc->outputLevel() ); + updateLog(); + + // call to the converter + ElementTable_PERS * etPers = m_TPConverter.createPersistent(etTrans, m_log ); + + return etPers; + +}//end of create persistent method + + +Trk::ElementTable* ElementTableCnv::createTransient() +{ + // Message stream handling + m_log.setLevel( m_msgSvc->outputLevel() ); + updateLog(); + + static pool::Guid p1_guid( "B157B642-94C0-11E3-B1C2-02163E00A511" ); + + Trk::ElementTable* tCollection = 0; + if( compareClassGuid( p1_guid ) ) { + + std::auto_ptr< ElementTable_PERS > p_coll( poolReadObject< ElementTable_PERS >() ); + tCollection = m_TPConverter.createTransient( p_coll.get(), m_log ); + } + + return tCollection; + +} + +void ElementTableCnv::updateLog(){ + + DataObject* dObj = getDataObject(); + if (dObj==0) return; // Can't do much if this fails. + const std::string key = (dObj->name()); + + m_log.m_source="ElementTableCnv: "+key; // A hack - relies on getting access to private data of MsgStream via #define trick. EJWM. +} diff --git a/Tracking/TrkDetDescr/TrkDetDescrAthenaPool/src/ElementTableCnv.h b/Tracking/TrkDetDescr/TrkDetDescrAthenaPool/src/ElementTableCnv.h new file mode 100644 index 0000000000000000000000000000000000000000..a59ef928e7cbf2097ad67c3a0e1d2adbce9efe31 --- /dev/null +++ b/Tracking/TrkDetDescr/TrkDetDescrAthenaPool/src/ElementTableCnv.h @@ -0,0 +1,53 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +////////////////////////////////////////////////////////////////// +// ElementTableCnv.h, (c) ATLAS Detector software +/////////////////////////////////////////////////////////////////// + +#ifndef ELELEMENTTABLE_CNV_H +#define ELELEMENTTABLE_CNV_H + +// ATLAS persistency way: +#define protected public +#include "GaudiKernel/MsgStream.h" +#undef protected + + +#include "AthenaPoolCnvSvc/T_AthenaPoolCustomCnv.h" + +// the transient side +#include "TrkGeometry/ElementTable.h" +// the perisistent side +#include "TrkDetDescrTPCnv/TrkGeometry/ElementTableCnv_p1.h" + +// useful typedefs to not change the code only once in case of schema evolution +typedef Trk::ElementTable_p1 ElementTable_PERS; +typedef T_AthenaPoolCustomCnv<Trk::ElementTable, ElementTable_PERS> ElementTableCnvBase; + + +class ElementTableCnv : public ElementTableCnvBase { + + friend class CnvFactory<ElementTableCnv>; + + protected: + + ElementTableCnv( ISvcLocator *svcloc ); + ~ElementTableCnv(); + + virtual StatusCode initialize(); + + virtual ElementTable_PERS* createPersistent( Trk::ElementTable *transCont); + virtual Trk::ElementTable* createTransient(); + + private: + void updateLog(); //!< This method modifies m_log to indicate the current key being converted + IMessageSvc* m_msgSvc; //!< MsgStream svc + MsgStream m_log; //!< MsgStream + + ElementTableCnv_p1 m_TPConverter; + +};//end of class definitions + +#endif // ELELEMENTTABLE_CNV_H diff --git a/Tracking/TrkDetDescr/TrkDetDescrAthenaPool/src/LayerMaterialCollectionCnv.cxx b/Tracking/TrkDetDescr/TrkDetDescrAthenaPool/src/LayerMaterialCollectionCnv.cxx deleted file mode 100644 index 361ba565141416a46495812f19bea360ac456a14..0000000000000000000000000000000000000000 --- a/Tracking/TrkDetDescr/TrkDetDescrAthenaPool/src/LayerMaterialCollectionCnv.cxx +++ /dev/null @@ -1,80 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -////////////////////////////////////////////////////////////////// -// LayerMaterialCollectionCollectionCnv.cxx, (c) ATLAS Detector software -/////////////////////////////////////////////////////////////////// - -#include "LayerMaterialCollectionCnv.h" -#include "GaudiKernel/IToolSvc.h" - -//----------------------------------------------------------------------------- -// Constructor -//----------------------------------------------------------------------------- -LayerMaterialCollectionCnv::LayerMaterialCollectionCnv(ISvcLocator* svcloc): - LayerMaterialCollectionCnvBase(svcloc), - m_msgSvc( msgSvc() ), - m_log( m_msgSvc, "LayerMaterialCollectionCnv" ) -{ -} - -//----------------------------------------------------------------------------- -// Destructor -//----------------------------------------------------------------------------- -LayerMaterialCollectionCnv::~LayerMaterialCollectionCnv() {} - -//----------------------------------------------------------------------------- -// Initializer -//----------------------------------------------------------------------------- -StatusCode LayerMaterialCollectionCnv::initialize() -{ - StatusCode sc = LayerMaterialCollectionCnvBase::initialize(); - if( sc.isFailure() ) { - m_log << MSG::FATAL << "Could not initialize cnv base" << endreq; - return sc; - } - //------------------------------------------------------------------------- - // Set up the message stream - //------------------------------------------------------------------------- - m_log.setLevel( m_msgSvc->outputLevel() ); - m_log << MSG::INFO << "LayerMaterialCollectionCnv::initialize()" << endreq; - - return StatusCode::SUCCESS; -} - -LayerMaterialCollection_PERS * -LayerMaterialCollectionCnv::createPersistent( Trk::LayerMaterialCollection *transCont) -{ - m_log.setLevel( m_msgSvc->outputLevel() ); - updateLog(); // Make m_log indicate the current key - return m_TPConverter_tlp1.createPersistent( transCont, m_log ); -} - - -//----------------------------------------------------------------------------- -// Create transient collection -//----------------------------------------------------------------------------- -Trk::LayerMaterialCollection *LayerMaterialCollectionCnv::createTransient() -{ - m_log.setLevel( m_msgSvc->outputLevel() ); - static pool::Guid tlp1_guid( "DFB29CDE-4618-4712-AB60-FEFEDB071415" ); - - Trk::LayerMaterialCollection *p_collection = 0; - - if( compareClassGuid( tlp1_guid ) ) { - poolReadObject< Trk::LayerMaterialCollection_tlp1 >( m_TPConverter_tlp1 ); - p_collection = m_TPConverter_tlp1.createTransient( m_log ); - } else - throw std::runtime_error( "Unsupported persistent version of Trk::LayerMaterialCollection (unknown GUID)" ); - - return p_collection; -} - -void LayerMaterialCollectionCnv::updateLog(){ - DataObject* dObj = getDataObject(); - if (dObj==0) return; // Can't do much if this fails. - const std::string key = (dObj->name()); - - m_log.m_source="LayerMaterialCollectionCnv: "+key; // A hack - relies on getting access to private data of MsgStream via #define trick. EJWM. -} \ No newline at end of file diff --git a/Tracking/TrkDetDescr/TrkDetDescrAthenaPool/src/LayerMaterialCollectionCnv.h b/Tracking/TrkDetDescr/TrkDetDescrAthenaPool/src/LayerMaterialCollectionCnv.h deleted file mode 100644 index c3a28dca292e52e4f2920f0e363627a8978a1cc6..0000000000000000000000000000000000000000 --- a/Tracking/TrkDetDescr/TrkDetDescrAthenaPool/src/LayerMaterialCollectionCnv.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -////////////////////////////////////////////////////////////////// -// LayerMaterialCollection.h, (c) ATLAS Detector software -/////////////////////////////////////////////////////////////////// - -#ifndef TRK_LAYERMATERIALCOLLCETION_CNV_H -#define TRK_LAYERMATERIALCOLLECTION_CNV_H - -// Hack so we can access the private data. EJWM -#define protected public -#include "GaudiKernel/MsgStream.h" -#undef protected - -#include "AthenaPoolCnvSvc/T_AthenaPoolCustomCnv.h" -#include "AthenaPoolCnvSvc/AthenaPoolCnvTPExtension.h" - -#include "TrkGeometry/LayerMaterialCollection.h" -#include "TrkDetDescrTPCnv/LayerMaterialCollectionCnv_tlp1.h" - -//----------------------------------------------------------------------------- -// Base class definition -//----------------------------------------------------------------------------- -typedef Trk::LayerMaterialCollection_tlp1 LayerMaterialCollection_PERS; - -typedef T_AthenaPoolCustomCnv<Trk::LayerMaterialCollection, LayerMaterialCollection_PERS> LayerMaterialCollectionCnvBase; - -//----------------------------------------------------------------------------- -// Converter for TrackCollection object -//----------------------------------------------------------------------------- -class LayerMaterialCollectionCnv - : public LayerMaterialCollectionCnvBase, - public AthenaPoolCnvTPExtension -{ -friend class CnvFactory<LayerMaterialCollectionCnv>; - -protected: - LayerMaterialCollectionCnv( ISvcLocator *svcloc ); - ~LayerMaterialCollectionCnv(); - virtual StatusCode initialize(); - - virtual LayerMaterialCollection_PERS *createPersistent( Trk::LayerMaterialCollection *transCont); - virtual Trk::LayerMaterialCollection *createTransient(); - - virtual AthenaPoolTopLevelTPCnvBase* getTopLevelTPCnv() { return &m_TPConverter_tlp1; } - -private: - void updateLog(); //!< This method modifies m_log to indicate the current key being converted - - IMessageSvc *m_msgSvc; - MsgStream m_log; - - LayerMaterialCollectionCnv_tlp1 m_TPConverter_tlp1; -}; - -#endif // TRK_LAYERMATERIALCOLLECTION_CNV_H diff --git a/Tracking/TrkDetDescr/TrkDetDescrAthenaPool/src/LayerMaterialMapCnv.h b/Tracking/TrkDetDescr/TrkDetDescrAthenaPool/src/LayerMaterialMapCnv.h index ab51069e46efcc9a723e0f93d4ec8e045db716ef..b0e9c04de5cc5ac6467205a4f72055435aeb7fa0 100644 --- a/Tracking/TrkDetDescr/TrkDetDescrAthenaPool/src/LayerMaterialMapCnv.h +++ b/Tracking/TrkDetDescr/TrkDetDescrAthenaPool/src/LayerMaterialMapCnv.h @@ -3,7 +3,7 @@ */ ////////////////////////////////////////////////////////////////// -// LayerMaterialMap.h, (c) ATLAS Detector software +// LayerMaterialMapCnv.h, (c) ATLAS Detector software /////////////////////////////////////////////////////////////////// #ifndef TRK_LAYERMATERIALMAP_CNV_H @@ -52,7 +52,7 @@ private: IMessageSvc *m_msgSvc; MsgStream m_log; - LayerMaterialMapCnv_tlp1 m_TPConverter_tlp1; + LayerMaterialMapCnv_tlp1 m_TPConverter_tlp1; }; #endif // TRK_LAYERMATERIALMAP_CNV_H