Cross-package initialization
IBM® Engineering Systems Design Rhapsody® has properties that enable you to specify code that initializes package relations after package instances are initialized, but before these instances react to events. More generally, these properties enable you to specify any other initialization code for each package in the model. They enable you to initialize cross-package relations from any of the packages that participate in the relation or from a package that does not participate in the relation.
The properties that govern package initialization code are as follows:
CG::Package::AdditionalInitialization
specifies additional initialization code to run after the execution of the packageinitRelations()
method.CG::Component::InitializationScheme
specifies at which level initialization occurs. The possible values are as follows:ByPackage
where each package is responsible for its own initialization; the component needs only to declare an attribute for each package class. This is the default option and maintains compatibility with earlier models of the product.ByComponent
where the component must initialize all global relations declared in all of its packages. This must be done by explicit calls in the component class constructor for each packageinitRelations()
, additional initialization, andstartBehavior()
.
The following example shows C++ code generated from
the model when the InitializationScheme
property
is set to ByPackage
.
The component code is as follows:
class DefaultComponent {
private :
P1_OMInitializer initializer_P1;
P2_OMInitializer initializer_P2;
};
The P1
package code
is as follows:
P1_OMInitializer::P1_OMInitializer() {
P1_initRelations();
< P1 AdditionalInitializationCode value>
P1_startBehavior();
}
The following example shows C++ component
code generated
when the InitializationScheme
property is set to ByComponent
:
DefaultComponent::DefaultComponent() {
P1_initRelations();
P2_initRelations();
< P1 AdditionalInitializationCode value>
< P2 AdditionalInitializationCode value>
P1_startBehavior();
P2_startBehavior();
}