1 //Dear emacs, this is -*- c++ -*-
4 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
7 #include "GaudiKernel/MsgStream.h"
8 #include "ByteStreamCnvSvcBase/ByteStreamAddress.h"
12 template< class DATATYPE >
13 TBDataCnv<DATATYPE>::TBDataCnv(ISvcLocator* svcloc) :
14 Converter(storageType(), classID(),svcloc),
19 template< class DATATYPE >
20 const CLID& TBDataCnv<DATATYPE>::classID(){
21 return ClassID_traits<DATATYPE>::ID() ;
24 template< class DATATYPE >
25 long TBDataCnv<DATATYPE>::storageType(){
26 return ByteStreamAddress::storageType() ;
29 template< class DATATYPE >
30 StatusCode TBDataCnv<DATATYPE>::initialize()
31 {StatusCode sc = Converter::initialize();
32 if (sc!=StatusCode::SUCCESS)
34 MsgStream logstr(msgSvc(), "TBDataCnv");
35 SmartIF<IToolSvc> toolSvc{service("ToolSvc")};
36 ATH_CHECK( toolSvc.isValid() );
38 ATH_CHECK( toolSvc->retrieveTool("TBByteStreamCnvTool",m_tool) );
40 return StatusCode::SUCCESS;
43 template< class DATATYPE >
44 StatusCode TBDataCnv<DATATYPE>::createObj(IOpaqueAddress* pAddr, DataObject*& pObj)
45 { MsgStream logstr(msgSvc(), "TBDataCnv");
46 ByteStreamAddress *pRE_Addr;
47 pRE_Addr = dynamic_cast<ByteStreamAddress*>(pAddr); //Cast from OpaqueAddress to ByteStreamAddress
49 {logstr << MSG::ERROR << "dynamic_cast of IOpaqueAdress to ByteStreamAddress failed!" << endmsg;
50 return StatusCode::FAILURE;
53 const std::string& key = *(pAddr->par()); // Get key used in the
54 // StoreGateSvc::retrieve function
55 StatusCode sc=m_tool->ReadFragment(tbdata,key);
56 if (sc!=StatusCode::SUCCESS) {
60 pObj = SG::asStorable(tbdata) ;
61 return StatusCode::SUCCESS;
64 template< class DATATYPE >
65 StatusCode TBDataCnv<DATATYPE>::createRep(DataObject* pObj, IOpaqueAddress*& pAddr)
67 std::string nm = pObj->registry()->name();
68 ByteStreamAddress* addr = new ByteStreamAddress(classID(),nm,"");
71 return m_tool->WriteFragment();