General structure
A product definition jython file defines behaviour when encountering an element according to its metaclass (represented by the product’s name).
For each particular model element being processed, the product definition associates the element with a particular ACT, and navigates to some other model elements (typically owned by the current element) to repeat the product process recursively.
File generation tasks
A file generation task contains the following parameters:
-
The element you want to generate on.
-
The relative path of at least one file to generate (usually both the "header" and "body" files).
-
The ID of a template that must be used to generate the file contents. IDs can be relative ("PackageGen") or absolute, with a specific variant name (for example, "standard.PackageGen").
You must use the PRODUCTS.addFileGeneration method.
Subproduct tasks
A subproduct task contains a list of all model elements to process the products on.
The sub-elements must be given in a List as a parameter of the PRODUCTS.addSubElements method.
Example
# Product definition for Package # Bound variables: # PRODUCT the product being build # ELT the element to generate import act from java.util import ArrayList from com.modeliosoft.modelio.api.mda.model import ObUtils if (CXX.isCxxElement(ELT) and not act.isNoCode(ELT)): # headerFile = CXX.makeNamespacePath(ELT) + "/" + CXX.makeCxxName(ELT) + "." + CXX.makeHeaderFileExtension(ELT) headerFile = CXX.makeDefaultHeaderFilePath(ELT) # bodyFile = CXX.makeNamespacePath(ELT) + "/" + CXX.makeCxxName(ELT) + "." + CXX.makeBodyFileExtension(ELT) bodyFile = CXX.makeDefaultBodyFilePath(ELT) files = ArrayList() if (act.isExternal(ELT)): if (ObUtils.isTagged (ELT, "Cxx.GenerateHeaderFile")): files.add(headerFile) else: files.add(headerFile) files.add(bodyFile) PRODUCT.addFileGeneration(ELT, files, "PackageGen") subelements = ELT.getOwnedElement() PRODUCT.addSubElements(subelements)