The wpInitData method initializes the Stack's instance data. Zero initialization
is statisfactory for the stack top pointer (pStackTop), so there is nothing
to do with respect to the instance data. However, I will take this opportunity
to increment the awake stack instance count being maintained by the class
because I want to decrement it in wpUnInitData. There are three additional
items to note when overriding wpInitData:
- The wpInitData method is invoked prior to the
determination or restoration of an object's state. It is therefore necessary
to be extremely careful about what other instance methods are called. It
is best to call none unless you wrote them.
- It is safest to call the parent's wpInitData
before doing your own initialization.
- If it is possible for this class to be a common
ancestor in a multiple inheritance scenario, then this method needs to be
written such that multiple invocations are handled. For example, if a class
named Stack23 was derived from classes Stack2 and Stack3 which in turn were
subclasses of Stack, that situation would exist. Not all Workplace Shell
classes (WP*) currently take this precaution. Therefore, it is advisable
to not inherit from more than one Workplace Shell class. Using SOM initializers
and destructors is an alternative to overriding wpInitData in the multiple
inheritance situation.
The following sample code shows the use of wpInitData:
SOM_Scope void SOMLINK stk_wpInitData( Stack *somSelf) // In - pointer to the object
{
StackData *somThis = StackGetData(somSelf);
StackMethodDebug("Stack","stk_wpInitData");
parent_wpInitData(somSelf);
if (!(_bInitialized))
{
_bInitialized = TRUE;
_clsIncObjectCount(_somGetClass(somSelf), STK_AWAKECOUNT);
} /* Endif */
return;
} // End stk_wpInitData
[Back]
[Next]