Transient Objects

As mentioned earlier in this chapter, a Workplace Shell object differs from a Presentation Manager window in that it is persistent; that is, it continues to exist after a system restart. The exception to this rule is the transient object, which only exists during the current execution of the system, and is destroyed when the system is IPLed.

Transient objects are useful when a programmer wishes to represent and display information such as records from a database. As each record is retrieved, a transient object is created for that record and displayed in a folder on the Workplace Shell desktop. These objects may be opened and manipulated by the end user, but will cease to exist when the system is IPLed.

Figure "Creating a Transient Object" shows an object window in a requester process which, upon receiving a completed database query from a server process, invokes the _wpclsNew method to create a new instance of a transient object class, representing the record retrieved from the database.

The SOM pointer to the transient object class is obtained using the SOMIdFromString() macro and the _somFindClass method (see Communication Between Objects for further information). This pointer is then used to invoke the _wpclsNew method to create a new instance of the class. Once the new instance is created, a method named _SetCustInfo, which is defined by the transient object class, is invoked to insert the information retrieved from the database into the object's instance data.

Note that the technique shown in Figure "Creating a Transient Object" may only be used when an object is created from within the Workplace Shell process. If an object must be created from another process in the system, the WinCreateObject() function must be used.


[Back: Accessing Presentation Manager Resources From a Workplace Shell Object]
[Next: Building a Workplace Shell Application]