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

7.4 Object containers<br />

As mentioned before, all objects which can be placed directly within one of the stores must be derived<br />

from the DataObject class. There is, however, another (indirect) way to store objects within a store.<br />

This is by putting a set of objects (themselves not derived from DataObject and thus not directly<br />

storable) into an object which is derived from DataObject and which may thus be registered into a<br />

store.<br />

An object container base class is implemented within the framework and a number of templated object<br />

container classes may be implemented in the future. For the moment, two “concrete” container classes<br />

are implemented: ObjectVector and ObjectList. These classes are based upon the<br />

STL classes and provide mostly the same interface. Unlike the STL containers which are essentially<br />

designed to hold objects, the container classes within the framework contain only pointers to objects,<br />

thus avoiding a lot of memory to memory copying.<br />

A further difference with the STL containers is that the type T cannot be anything you like. It must be a<br />

type derived from the ContainedObject base class, see Figure 7.1. In this way all “contained”<br />

objects have a pointer back to their containing object. This is required, in particular, by the converters<br />

for dealing with links between objects. A ramification of this is that container objects may not contain<br />

other container objects (without the use of multiple inheritance).<br />

DataObject<br />

ObjectContainerBase<br />

parent<br />

ContainedObject<br />

T<br />

ObjectVector<br />

T<br />

Figure 7.1 The relationship between the DataObject, ObjectVector and ContainedObject classes.<br />

As mentioned above, objects which are contained within one of these container objects may not be<br />

located, or registered, individually within the store. Only the container object may be located via a call<br />

to findObject() or retrieveObject(). Thus with regard to interaction with the data stores a<br />

container object and the objects that it contains behave as a single object.<br />

page 47

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

Saved successfully!

Ooh no, something went wrong!