23.05.2014 Views

Athena Developer Guide

Athena Developer Guide

Athena Developer Guide

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>Athena</strong> Chapter 15 Converters Version/Issue: 2.0.0<br />

i. “Macroscopic” references appear as separate “leaves” in the data store. They have to be<br />

registered with a separate opaque address structure in the data directory of the object being<br />

converted. This must be done after the object was registered in the data store in the method<br />

fillObjRefs().<br />

ii.<br />

Internal references must be handled differently. There are two possibilities for resolving<br />

internal references:<br />

1. Load on demand: If the object the reference points to should only be loaded when<br />

accessed, the pointer must no longer be a raw C++ pointer, but rather a smart pointer<br />

object containing itself the information for later resolution of the reference. This is<br />

the preferred solution for references to objects within the same data store, e.g.<br />

references from the Monte-Carlo tracks to the Monte-Carlo vertices. Please see in<br />

the corresponding SICB converter implementations how to construct these smart<br />

pointer objects. Late loading is highly preferable compared to the second possibility.<br />

2. Filling of raw C++ pointers: Here things are a little more complicated and introduces<br />

the need for a second step in the process. This is only necessary if the object points<br />

to an object in another store, e.g. the detector data store. To resolve the reference a<br />

converter has to retrieve the other object and set the raw pointer. These references<br />

should be set in the fillObjRefs() method. This of course is more complicated,<br />

because it must be ensured that both objects are present at the time the reference is<br />

accessed (i.e. when the pointer is actually used).<br />

15.5 Converter implementation - general considerations<br />

page 142<br />

After covering the ground work in the preceding sections, let us look exactly what needs to be<br />

implemented in a specific converter class. The starting point is the Converter base class from which<br />

a user converter should be derived. For concreteness let us partially develop a converter for the UDO<br />

class of Chapter 7.<br />

The converter shown in Listing 15.1 is responsible for the conversion of UDO type objects into objects<br />

that may be stored into an Objectivity database and vice-versa. The UDOCnv constructor calls the<br />

Converter base class constructor with two arguments which contain this information. These are the<br />

values CLID_UDO, defined in the UDO class, and Objectivity_StorageType which is also<br />

defined elsewhere. The first two extern statements simply state that these two identifiers are defined<br />

elsewhere.<br />

All of the “book-keeping” can now be done by the Converter base class. It only remains to fill in the<br />

guts of the converter. If objects of type UDO have no links to other objects, then it suffices to implement<br />

the methods createRep() for conversion from the transient form (to Objectivity in this case) and<br />

createObj() for the conversion to the transient form.<br />

If the object contains links to other objects then it is also necessary to implement the methods<br />

fillRepRefs() and fillObjRefs().

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!