next up previous contents
Next: Caveats to using KeyPtr's Up: Database access Previous: Reading TPhKeyPtr's   Contents

Writing TPhKeyPtr's

The second way of making a TPhKeyPtr is to write out an object which is not yet in the database to the database, defining its key in the process. The way this is expresses is by making a pairing of a Key and its object - which does an implicit write to the database.4 For example:

TPhPedestalSet *mypeds; 
// I've just calculated mypeds for run 2119 somewhere else.
TPhKeyPtr<TPhPedestalSet> peds(TPhCalKey("SIPED",2119,"PHAT5"),mypeds);
This is very similar to the previous, except for the explicit specifying of an actual key, not asking for the ``best'' key - note that the previous Select function could well have returned this pedestal set, if it had been in the database and no other sets were in for runs 2120 or 2121 - and the explicit specifying of the object pointed to, in this case mypeds. It is the fact that these are explicitly specified that makes the system write the new association into the database.



Gunther Roland
2000-05-05