Jump to content

wpInitData

From EDM2

This instance method is called to allow the object to initialize its instance data.

Syntax

wpInitData(somSelf)

Parameters

somSelf (WPObject *) - input
Pointer to the object on which the method is being invoked.
Points to an object of class WPObject.

Returns

There is no return value for this method.

Remarks

This routine is called by the system when the object is created or when it is awakened from the dormant state so that it can initialize all of its instance variables to a known state. By default, memory allocated to instance variables is zerofilled. Note that this method is called before the object's state is known, so it is very important that the object does not try to process any other method while processing this method. Should an object need extra initialization that requires it to invoke other methods, this should be done from wpRestoreState. When the object is first created, wpSetupOnce should be overridden to perform initialization that is required only once. The parent method must be called before any processing is done by your overriding method.

Usage

This method is generally called only by the system when the object is awakened.

How to Override

Any class that has instance variables should override this method so that those variables are all initially in a known state. It is essential to pass this method onto the parent class before doing your own processing. If this method is overridden, wpUnInitData should also be overridden in order to de-allocate resources that were allocated by the override processing of wpInitData.

Example Code

This example initializes state variables and allocates any extra memory that might be needed.

SOM_Scope void SOMLINK myf_wpInitData(MYFILE *somSelf)
{
    MYFILEData *somThis = MYFILEGetData(somSelf);
    MYFILEMethodDebug("MYFILE","myf_wpInitData");

    parent_wpInitData(somSelf);    /* Have parent method do initialization */

    _pszLastWorker = (PSZ) _wpAllocMem(somSelf,
                                       CCHMAXPATH+1,  /* Number of bytes */
                                       NULL);        /* Return error message */

    if (_pszLastWorker) {

      strcpy(_pszLastWorker, DEFAULT_LASTWORKER);

    } /* endif */

}

Related Methods