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><br />

Chapter 7 Accessing data Version/Issue: 2.0.0<br />

The thing to note here is that if the appropriate converter is supplied, as discussed in Chapter 15, then<br />

this class may also be saved into a persistent store (e.g. a ROOT file or an Objectivity database) and<br />

read back at a later date. In order for the persistency to work the following are required: the unique class<br />

identifier number (CLID_UDO in the example), and the clID() and classID() methods which<br />

return this identifier.<br />

The procedure for allocating unique class identifiers is, for the time being, experiment specific.<br />

Types which are derived from ContainedObject are implemented in the same way, and must have<br />

a CLID in the range of an unsigned short. Contained objects may only reside in the store when<br />

they belong to a container, e.g. an ObjectVector which is registered into the store. The class<br />

identifier of a concrete object container class is calculated (at run time) from the type of the objects<br />

which it contains, by setting bit 16. The static classID() method is required because the container<br />

may be empty.<br />

7.8 The SmartDataPtr/SmartDataLocator utilities<br />

The usage of the data services is simple, but extensive status checking and other things tend to make the<br />

code difficult to read. It would be more convenient to access data items in the store in a similar way to<br />

accessing objects with a C++ pointer. This is achieved with smart pointers, which hide the internals of<br />

the data services.<br />

7.8.1 Using SmartDataPtr/SmartDataLocator objects<br />

The SmartDataPtr and a SmartDataLocator are smart pointers that differ by the access to the<br />

data store. SmartDataPtr first checks whether the requested object is present in the transient store<br />

and loads it if necessary (similar to the retrieveObject method of IDataProviderSvc).<br />

SmartDataLocator only checks for the presence of the object but does not attempt to load it<br />

(similar to findObject).<br />

Both SmartDataPtr and SmartDataLocator objects use the data service to get hold of the<br />

requested object and deliver it to the user. Since both objects have similar behaviour and the same user<br />

interface, in the following only the SmartDataPtr is discussed.<br />

page 51

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

Saved successfully!

Ooh no, something went wrong!