Skip to main content

Notice: This Wiki is now read only and edits are no longer possible. Please see: for the plan.

Jump to: navigation, search

Papyrus-RT/Developer/Design/0.8/Codegen API


Code Generation Interface


The code generator presents a function-based interface to the toolset. The function parameter list contains the elements to be generated.

package com.zeligsoft.umlrt.papyrus;

import java.util.List;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.emf.ecore.EObject;

class UMLRTCppCodeGen
    public static IStatus generate( List<EObject> elements );

The generator is incremental. The toolset is expected to provide a list of only the elements that have directly changed since the generator was last invoked. The code generator implements the code pattern and therefore is the component that is able to compute the full set of elements that could be affected by any one change.

The rest of this document describes the model elements that can be passed to the generator and the effect of each.

UML-RT Elements

This list of elements in UML-RT stereotyped models has been collected from the document "A UML-RT Profile for the Papyrus Tool". A later section prunes this complete list to the set that is accepted by the generator.

  • Model
  • Package
  • Protocol
  • Capsule
  • StateMachine

Generatable Elements

The generator iterates over the list of provided elements. For each valid element it will generate any applicable code. Depending on the type of element it may also visit related elements. Each visited element will be processed in the same way (generate applicable code and visit related elements).

The following table lists the elements that can be passed to the #generate function and describes the generator's response for each.

Element CodeGen Behaviour Notes
Model visit entire model This is to be used for new models or for cases where the toolset has lost tracking of changes. The alternative is to have the toolset walk the entire model passing the contained elements separately. The generator will then be revisiting alot of the same relationships. Allowing the toolset to pass just the higher level element allows the overall operation to be more efficient.
Package visit entire package See notes for Model.
Protocol generates protocol-specific code The generator expects the <> stereotype'ed package
Capsule generates capsule-specific code, visits ports and derived capsules The Capsule should be the generation element for structural changes. The structural elements will affect code generated for the capsule as well as all derived capsules.
StateMachine generates code for entire state machine The code pattern for the state machine is likely to be tightly coupled. A single change in part of the state machine is likely to impact generation of many other elements of the state machine.
NOTE: The list of generatable elements will evolve during development. The reason this list is specified is to provide better incremental codegen performance. A small change in the model should cause a small amount of work for the code generator. Any change to the set of generatable elements should always be decided based on how it affects performance of incremental generation.

Back to the top