Union mapping for IDL (IDL code)
For each Union, ACS generates a union declaration in the appropriate IDL file. ACS generates code similar to this:
// Type declarations
union Union1 switch (Typedef1)
{
case MyCase1: char Attribute2;
case MyCase2: char Attribute3
default: char Attribute1;
};
ACS uses Unions for generating the content of a Deployment Plan's Component Deployment Plan (CDP) file.
In Modeler, a Union is a Class that has its Union check box selected on its Property Pages. However, ACS generates a Class as a union only when the «CORBAUnion» stereotype is applied to the Class.
Child Attributes are used to define the switch type, cases and the default.
Discriminant Attribute
The discriminant of the Union is defined through the data type of a child Attribute that is stereotyped by the «CORBASwitch» stereotype.
For example, if a Union owns a child Attribute that is stereotyped by the «CORBASwitch» stereotype and that Attribute uses Typedef1 as its data type, the following discriminant is generated.
union Union1 switch (Typedef1)
Case Attribute
Each case of the Union is defined through a child Attribute that is stereotyped by the «CORBACase» stereotype. The name of the case is specified through the tagged value of the label tag definition that is applied by the «CORBACase» stereotype.
For example, if a Union owns an Attribute named Attribute2 that is stereotyped by the «CORBACase» stereotype, and that Attribute uses char as its data type and has the tagged value of its Label tag definition set to MyCase1, ACS generates the following case.
case MyCase1: char Attribute2;
Default Attribute
The default case of the Union is defined through a child Attribute that is stereotyped by the «CORBADefault» stereotype.
For example, if a Union owns an Attribute named Attribute1 that is stereotyped by the «CORBADefault» stereotype and that Attribute uses char as its data type, ACS generates the following default case.
default: char Attribute1;
The generation of a Union in an IDL file is derived from the items it owns, properties of the Union, and the tagged values set for Tag Definitions applied by the «Union» stereotype. Note that the «Source» stereotype from the IDL Profile does not apply to Unions.
Child items:
• If the Union owns Attributes, those Attributes can be used to generate the switch type, cases and the default:
◦ An Attribute that is stereotyped by the «CORBASwitch» stereotype is generated as the switch type.
◦ An Attribute that is stereotyped by the «CORBACase» stereotype is generated as a case.
◦ An Attribute that is stereotyped by the «CORBADefault» stereotype is generated as the default case.
Properties:
• If the Description property has a value, ACS generates the Description as a comment on the line before the union declaration.
• ACS generates the Name property as the name of the union.
Note ACS may modify the union name that is added to the code to make it valid for IDL. You can specify the exact union name to add to the code through the CODE_GENERATION_NAME property of a Class.
Other properties are ignored.
Tag Definitions:
The following Tag Definitions that can be applied to a Union through the «Source» stereotype from the IDL Profile.
• If the tagged value of the ignore tag definition is set to FALSE, ACS does not generate the Union.
• The includes and file name tag definitions do not apply to Unions.