Athena Developer Guide
Athena Developer Guide
Athena Developer Guide
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
<strong>Athena</strong><br />
Chapter 15 Converters Version/Issue: 2.0.0<br />
The instantiation of the appropriate converter is done by a macro. The macro instantiates also the<br />
converter factory used to instantiate the requested converter. Hence, all other user code is shielded from<br />
the implementation and definitions of the ROOT specific code.<br />
Listing 15.2 Implementing a “generic” converter for the transient class Event.<br />
1: // Include files<br />
2: #include "GaudiKernel/ObjectVector.h"<br />
3: #include "GaudiKernel/ObjectList.h"<br />
4: #include "GaudiDb/DbGenericConverter.h"<br />
5: // Converter implementation for objects of class Event<br />
6: #include "Event.h"<br />
7: _ImplementConverter(Event)<br />
The macro needs a few words of explanation: the instantiated converters are able to create transient<br />
objects of type Event. The corresponding persistent type is of a generic type, the data are stored as a<br />
machine independent byte stream. It is mandatory that the Event class implements a streamer method<br />
“serialize”. An example from the Event class of the RootIO example is shown in Listing 15.3.<br />
The instantiated converter is of the type DbGenericConverter and the instance of the instantiating<br />
factory has the instance name DbEventCnvFactory.<br />
Listing 15.3 Serialisation of the class Event.<br />
1: /// Serialize the object for writing<br />
2: virtual StreamBuffer& serialize( StreamBuffer& s ) const {<br />
3: DataObject::serialize(s);<br />
4: return s<br />
5: > m_run<br />
15: >> m_time;<br />
16: }<br />
15.7.1 Non Identifiable Objects<br />
Non identifiable objects cannot directly be retrieved/stored from the data store. Usually they are small<br />
and in any case they are contained by a container object. Examples are particles, hits or vertices. These<br />
classes can be converted using a generic container converter. Container converters exist currently for<br />
lists and vectors. The containers rely on the serialize methods of the contained objects. The serialisation<br />
is able to understand smart references to other objects within the same data store. Listing 15.4 shows an<br />
example of the serialize methods of the MyTrack class of the RootIO example<br />
page 145