ATLAS Offline Software
Loading...
Searching...
No Matches
Athena::LeafCnv Class Reference

#include <LeafCnv.h>

Inheritance diagram for Athena::LeafCnv:
Collaboration diagram for Athena::LeafCnv:

Public Member Functions

 LeafCnv (const CLID &clid, ISvcLocator *pSvcLocator)
 Constructor with parameters:
 LeafCnv (ISvcLocator *pSvcLocator)
virtual ~LeafCnv ()
 Destructor:
virtual StatusCode initialize ()
 Gaudi Service Implementation.
long repSvcType () const
virtual StatusCode createObj (IOpaqueAddress *pAddr, DataObject *&pObj)
 Create a transient object from a persistent representation.
virtual StatusCode createRep (DataObject *pObj, IOpaqueAddress *&pAddr)
 Create a persistent representation for a transient object.
bool msgLvl (const MSG::Level lvl) const
 Test the output level.
MsgStream & msg () const
 The standard message stream.
MsgStream & msg (const MSG::Level lvl) const
 The standard message stream.
void setLevel (MSG::Level lvl)
 Change the current logging level.

Static Public Member Functions

static long storageType ()
static const CLID & classID ()

Private Member Functions

void initMessaging () const
 Initialize our message level and MessageSvc.

Private Attributes

RootType m_type
 the type we can convert
std::string m_nm
 Message source name.
boost::thread_specific_ptr< MsgStream > m_msg_tls
 MsgStream instance (a std::cout like with print-out levels).
std::atomic< IMessageSvc * > m_imsg { nullptr }
 MessageSvc pointer.
std::atomic< MSG::Level > m_lvl { MSG::NIL }
 Current logging level.
std::atomic_flag m_initialized ATLAS_THREAD_SAFE = ATOMIC_FLAG_INIT
 Messaging initialized (initMessaging).

Detailed Description

Definition at line 34 of file LeafCnv.h.

Constructor & Destructor Documentation

◆ LeafCnv() [1/2]

Athena::LeafCnv::LeafCnv ( const CLID & clid,
ISvcLocator * pSvcLocator )

Constructor with parameters:

Definition at line 53 of file LeafCnv.cxx.

54 :
55 ::Converter( ROOT_StorageType, clid, pSvcLocator ),
56 ::AthMessaging( msgSvc(), name_from_clid(clid) ),
57 m_type()
58{
59 //
60 // Property declaration
61 //
62 //declareProperty( "Property", m_nProperty );
63
64}
AthMessaging()
Default constructor:
RootType m_type
the type we can convert
Definition LeafCnv.h:89

◆ LeafCnv() [2/2]

Athena::LeafCnv::LeafCnv ( ISvcLocator * pSvcLocator)

Definition at line 66 of file LeafCnv.cxx.

66 :
67 ::Converter ( ROOT_StorageType, CLID_NULL, pSvcLocator ),
68 ::AthMessaging( msgSvc(), name_from_clid(CLID_NULL) ),
69 m_type()
70{
71 //
72 // Property declaration
73 //
74 //declareProperty( "Property", m_nProperty );
75
76}

◆ ~LeafCnv()

Athena::LeafCnv::~LeafCnv ( )
virtual

Destructor:

Definition at line 80 of file LeafCnv.cxx.

81{
82 ATH_MSG_DEBUG("Calling destructor");
83}
#define ATH_MSG_DEBUG(x,...)

Member Function Documentation

◆ classID()

const CLID & Athena::LeafCnv::classID ( )
inlinestatic
Returns
class ID.

Definition at line 80 of file LeafCnv.h.

80{ return CLID_NULL; }

◆ createObj()

StatusCode Athena::LeafCnv::createObj ( IOpaqueAddress * pAddr,
DataObject *& pObj )
virtual

Create a transient object from a persistent representation.

Parameters
pAddr[IN] IOpaqueAddress of persistent representation.
pObj[OUT] pointer to the transient object.

Definition at line 140 of file LeafCnv.cxx.

141{
142 ATH_MSG_DEBUG("::createObj(" << pAddr << ", " << pObj << ")");
143 Athena::RootBranchAddress *rba = dynamic_cast<Athena::RootBranchAddress*>(pAddr);
144 if (!rba) {
145 ATH_MSG_DEBUG(*pAddr->par() << " is NOT a GenericAddress!");
146 return StatusCode::FAILURE;
147 }
148 ATH_MSG_DEBUG("loading branch: [" << rba->par()[0]
149 << "/" << rba->par()[1] << "]...");
151 ATH_MSG_DEBUG("loading branch: [" << rba->par()[0]
152 << "/" << rba->par()[1] << "]... [done]");
153 Athena::DataBucketBranch *dbb = new DataBucketBranch(rba->clID(), rba->m_type, rba->m_ptr);
154 pObj = dbb;
155 return StatusCode::SUCCESS;
156}
void setBranchAddress(const RootType &t)
setup the ROOT TTree internal address for the branch.
RootType m_type
the buffer for the TBranch

◆ createRep()

StatusCode Athena::LeafCnv::createRep ( DataObject * pObj,
IOpaqueAddress *& pAddr )
virtual

Create a persistent representation for a transient object.

Parameters
pObj[IN] pointer to the transient object.
pAddr[OUT] IOpaqueAddress of persistent representation.

Definition at line 162 of file LeafCnv.cxx.

163{
164 ATH_MSG_INFO("::createRep(" << pObj << ", " << pAddr << ")");
165 if (0==pObj) {
166 ATH_MSG_ERROR("::createRep: received null ptr to dobj");
167 return StatusCode::FAILURE;
168 }
169 msg(MSG::INFO) << " -> clid: [" << pObj->clID() << "]" << endmsg
170 << " -> name: [" << pObj->name() << "]" << endmsg;
171
172 /*
173 Athena::DataBucketBranch *dbb = 0;
174 dbb = dynamic_cast<Athena::DataBucketBranch*>(pObj);
175 if (!dbb) {
176 ATH_MSG_INFO("dataobject at [" << pObj->name() << "] is not"
177 << " a DataBucketBranch ! [clid=" << pObj->clID() << "]");
178 return StatusCode::FAILURE;
179 }
180 */
181
182 // FIXME:
183 // Athena::RootBranchAddress* addr = new Athena::RootBranchAddress
184 // (ROOT_StorageType,
185 // dbb->clID(),
186 // m_tupleName.value(),
187 // br_name,
188 // (unsigned long)(value_ptr),
189 // (unsigned long)(m_nbrEvts-1));
190#if 1
191 GenericAddress* addr = new GenericAddress(ROOT_StorageType,
192 pObj->clID(),
193 pObj->name());
194#else
195 Athena::RootBranchAddress* addr = new Athena::RootBranchAddress
196 (ROOT_StorageType, id,
197 "foo",//m_tupleName.value(),
198 dbb->name(),
199 (unsigned long)(value_ptr),
200 (unsigned long)(m_nbrEvts-1));
201#endif
202 pAddr = addr;
203 return StatusCode::SUCCESS;
204}
#define endmsg
#define ATH_MSG_ERROR(x,...)
#define ATH_MSG_INFO(x,...)
MsgStream & msg() const
The standard message stream.

◆ initialize()

StatusCode Athena::LeafCnv::initialize ( )
virtual

Gaudi Service Implementation.

Definition at line 87 of file LeafCnv.cxx.

88{
89 // configure our MsgStream
90 msg().setLevel( MSG::INFO );
91
92 ATH_MSG_DEBUG("Initializing LeafCnv...");
93
94 ATH_MSG_DEBUG("Initializing base class...");
95 if ( ::Converter::initialize().isFailure() ) {
96 ATH_MSG_ERROR("Could not intialize base class !!");
97 return StatusCode::FAILURE;
98 } else {
99 ATH_MSG_VERBOSE("Base class initialized");
100 }
101
102 // retrieve the dict-loader-svc
103 typedef ServiceHandle<IDictLoaderSvc> IDictLoaderSvc_t;
104 IDictLoaderSvc_t dictSvc("AthDictLoaderSvc",
105 "Athena::LeafCnv");
106 // name_from_clid(objType()));
107 if ( !dictSvc.retrieve().isSuccess() ) {
108 ATH_MSG_ERROR("could not retrieve [" << dictSvc.typeAndName() << "] !");
109 return StatusCode::FAILURE;
110 }
111
112 RootType ty = dictSvc->load_type(this->objType());
113 ATH_MSG_VERBOSE("loaded dictionary for clid ["
114 << this->objType() << "]: name=["
115 << ty.Name() << "]");
116 m_type = std::move(ty);
117
118 ATH_MSG_DEBUG("converter correctly initialized - clid=[" << objType() << "]");
119 return StatusCode::SUCCESS;
120}
#define ATH_MSG_VERBOSE(x,...)
TTypeAdapter RootType
Definition RootType.h:211
std::string Name(unsigned int mod=Reflex::SCOPED) const
Definition RootType.cxx:610

◆ initMessaging()

void AthMessaging::initMessaging ( ) const
privateinherited

Initialize our message level and MessageSvc.

This method should only be called once.

Definition at line 39 of file AthMessaging.cxx.

40{
42 // If user did not set an explicit level, set a default
43 if (m_lvl == MSG::NIL) {
44 m_lvl = m_imsg ?
45 static_cast<MSG::Level>( m_imsg.load()->outputLevel(m_nm) ) :
46 MSG::INFO;
47 }
48}
std::string m_nm
Message source name.
std::atomic< IMessageSvc * > m_imsg
MessageSvc pointer.
std::atomic< MSG::Level > m_lvl
Current logging level.
IMessageSvc * getMessageSvc(bool quiet=false)
int outputLevel(const IMessageSvc *ims, const std::string &source)

◆ msg() [1/2]

MsgStream & AthMessaging::msg ( ) const
inlineinherited

The standard message stream.

Returns a reference to the default message stream May not be invoked before sysInitialize() has been invoked.

Definition at line 167 of file AthMessaging.h.

168{
169 MsgStream* ms = m_msg_tls.get();
170 if (!ms) {
171 if (!m_initialized.test_and_set()) initMessaging();
172 ms = new MsgStream(m_imsg,m_nm);
173 m_msg_tls.reset( ms );
174 }
175
176 ms->setLevel (m_lvl);
177 return *ms;
178}
boost::thread_specific_ptr< MsgStream > m_msg_tls
MsgStream instance (a std::cout like with print-out levels).
void initMessaging() const
Initialize our message level and MessageSvc.

◆ msg() [2/2]

MsgStream & AthMessaging::msg ( const MSG::Level lvl) const
inlineinherited

The standard message stream.

Returns a reference to the default message stream May not be invoked before sysInitialize() has been invoked.

Definition at line 182 of file AthMessaging.h.

183{ return msg() << lvl; }

◆ msgLvl()

bool AthMessaging::msgLvl ( const MSG::Level lvl) const
inlineinherited

Test the output level.

Parameters
lvlThe message level to test against
Returns
boolean Indicating if messages at given level will be printed
Return values
trueMessages at level "lvl" will be printed

Definition at line 151 of file AthMessaging.h.

152{
153 // If user did not set explicit message level we have to initialize
154 // the messaging and retrieve the default via the MessageSvc.
155 if (m_lvl==MSG::NIL && !m_initialized.test_and_set()) initMessaging();
156
157 if (m_lvl <= lvl) {
158 msg() << lvl;
159 return true;
160 } else {
161 return false;
162 }
163}

◆ repSvcType()

long Athena::LeafCnv::repSvcType ( ) const

Definition at line 127 of file LeafCnv.cxx.

128{
129 return ROOT_StorageType;
130}

◆ setLevel()

void AthMessaging::setLevel ( MSG::Level lvl)
inherited

Change the current logging level.

Use this rather than msg().setLevel() for proper operation with MT.

Definition at line 28 of file AthMessaging.cxx.

29{
30 m_lvl = lvl;
31}

◆ storageType()

long Athena::LeafCnv::storageType ( )
static
Returns
storage type.

Definition at line 207 of file LeafCnv.cxx.

208{
209 return ROOT_StorageType;
210}

Member Data Documentation

◆ ATLAS_THREAD_SAFE

std::atomic_flag m_initialized AthMessaging::ATLAS_THREAD_SAFE = ATOMIC_FLAG_INIT
mutableprivateinherited

Messaging initialized (initMessaging).

Definition at line 141 of file AthMessaging.h.

◆ m_imsg

std::atomic<IMessageSvc*> AthMessaging::m_imsg { nullptr }
mutableprivateinherited

MessageSvc pointer.

Definition at line 135 of file AthMessaging.h.

135{ nullptr };

◆ m_lvl

std::atomic<MSG::Level> AthMessaging::m_lvl { MSG::NIL }
mutableprivateinherited

Current logging level.

Definition at line 138 of file AthMessaging.h.

138{ MSG::NIL };

◆ m_msg_tls

boost::thread_specific_ptr<MsgStream> AthMessaging::m_msg_tls
mutableprivateinherited

MsgStream instance (a std::cout like with print-out levels).

Definition at line 132 of file AthMessaging.h.

◆ m_nm

std::string AthMessaging::m_nm
privateinherited

Message source name.

Definition at line 129 of file AthMessaging.h.

◆ m_type

RootType Athena::LeafCnv::m_type
private

the type we can convert

Definition at line 89 of file LeafCnv.h.


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