25.01.2015 Views

Using Caché Objects - InterSystems Documentation

Using Caché Objects - InterSystems Documentation

Using Caché Objects - InterSystems Documentation

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>Using</strong> Callback Methods<br />

Since different types of classes support different events, not all callback methods are available<br />

to all classes. For example, callback methods triggered by saving or deleting an object cannot<br />

be accessed by registered objects since these objects cannot be saved or deleted.<br />

With the exception of %OnDetermineClass, these methods can be used to perform any<br />

processing desired at the relevant event.<br />

%OnDetermineClass is a special case. When %Open or %Delete is given a partially-formed<br />

OID, it calls the %OnDetermineClass method, if the user has provided one, to obtain the<br />

actual class name. If %OnDetermineClass indicates the object belongs to a different class,<br />

%Open or %Delete will dispatch to the new class' %Open or %Delete method. If there is<br />

no %OnDetermineClass method, %Open and %Delete simply assume the current class is<br />

the correct class.<br />

20.1 %OnAddToSaveSet<br />

This instance method is called by the %AddToSaveSet method. The %AddToSaveSet<br />

method itself is called on an object whose %Save method has been invoked, as well as all<br />

other objects referenced by that object that have been loaded into memory. %AddToSaveSet<br />

can also be invoked directly from %OnAddToSaveSet. If %OnAddToSaveSet modifies<br />

another object, then it is the responsibility of %OnAddToSaveSet to invoke %AddToSaveSet<br />

on that modified object.<br />

When you invoke %Save on an object, called, for example, MyPerson, <strong>Caché</strong> generates a<br />

list of objects that MyPerson references. A SaveSet is the list of objects consisting of the<br />

object to be saved and all the objects that it references. In the example, the SaveSet might<br />

include referenced objects MySpouse, MyDoctor, and so on.<br />

The syntax of %OnAddToSaveSet is:<br />

ReturnValue %OnAddToSaveSet(SaveDepth As %Integer, Insert As %Integer,<br />

CallCount As %Integer)<br />

where:<br />

170 <strong>Using</strong> <strong>Caché</strong> <strong>Objects</strong>

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

Saved successfully!

Ooh no, something went wrong!