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.

Property Accessors<br />

7.4 Property Accessors<br />

The <strong>Caché</strong> dot syntax for referring to properties is an interface for a set of accessor methods<br />

to retrieve and set values. For each property, whenever the code refers to oref.Prop (where<br />

oref is an object and Prop is a property), it is executed as if a system-supplied PropGet or<br />

PropSet method were invoked. For example:<br />

Set person.DOB = x<br />

acts as if the following method was called:<br />

Do person.DOBSet(x)<br />

while:<br />

Write person.Name<br />

acts like:<br />

Write person.NameGet()<br />

It is important to point out that in most cases, there are no actual PropGet and PropSet<br />

methods; access for simple properties is implemented directly within the <strong>Caché</strong> virtual machine<br />

for optimal performance. You can, however, provide PropGet and PropSet methods for a<br />

specific property. In this case, these accessor methods will be invoked at runtime automatically.<br />

Typically, every property has process-private, in-memory storage allocated for it. The systemprovided<br />

property accessors use this storage directly. Note that this object storage is not held<br />

in the local variable symbol table and is not affected by the Kill command.<br />

If you need to access the in-memory stored value of a property from within an instance method<br />

of an object, you can use the following in-memory value syntax:<br />

Set i%Name = "Carl"<br />

This directly sets “Carl” as the in-memory value of the property Name, bypassing the NameSet<br />

accessor (if present).<br />

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

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

Saved successfully!

Ooh no, something went wrong!