About this task
The
following code generation semantics
apply to component diagrams:
- Code generation
is provided for library and executable
build type components.
- Code generation is provided
for folder and file
component-related metatypes.
- Code is generated
only with regard to relations
between the binary components (library and executable file).
- The following parts of a component diagram provide
no code generation:
- Relations involving files
and folders
- Interfaces realized by a component
- All other component types that are not stereotyped «Library» or «Executable»
- A dependency between components generates
code
only if it has the «Usage» stereotype, with the following
restrictions:
The CG::Component::ComponentsSearchPath property
specifies the name of related components, although the dependencies
are checked before the property. For example, a dependency from component A to
component B is equivalent to putting B in
the ComponentsSearchPath property (with the obvious
advantage on name change recovery).
Consider
the diagrams shown in the following figure.
Classes C1 and C2 have
a relation to each other (an association). The model has two components, component_1 and component_2,
that each have a configuration with the same name. Component_1 has
a dependency with stereotype «Usage» to component_2.
Class C1 is in the scope of component_1.
Class C2 is not in the scope of component_1,
but is mapped to a file F1 in component_2.
- Look for an element file name in related components
(when the element is not in the scope of the current component).
For example, when generating component_1, when IBM® Rational® Rhapsody® needs
to include C2, it will include F1 (the
file in component_2).
- Add
related components to the makefile include
path. For example, in the component_1 makefile, a
new line
is added to the include path with the location of component_2.
- If the current component build type is executable,
and a related component build type is library, add the library to
the build of the current component. For example, if the build type
of component_1 is executable, and the build type
of component_2 is library, the component_1 makefile
will include
the library of component_2 in its build.