• 1 reply
  • Latest Post - ‏2013-07-05T16:04:07Z by bregan
2 Posts

Pinned topic Java Api: Add code to generated files

‏2013-06-24T10:51:43Z |


I am trying to add code to entry actions in states and actions in transitions in a model programatically through the Java API. This alone works fine, but what I would really like to do is add the code only to the generated .cpp files and not to the model. To clarify, the code should only be visible in the generated files and not the model.


Something like this:

//# [preserve

cout << "At state 1";



If you need more info just let me know and I will try to provide it.



  • bregan
    27 Posts

    Re: Java Api: Add code to generated files


    We have successfully used the 'post-simplifier' to perform something similar.

    I have previously found the documentation of this pretty spotty - but IBM provides an example (path is from R8.0) here: \Samples\CustomCG Samples\VisibilityGrouping\src\com\ibm\rational\rhapsody\visibilityGrouping\simplification

    The way it works is to pass control to software that you write (java, vba, etc)  at an intermediate point in code generation which is after it has created the thing they call the 'simplified model'  (a normally invisible intermediate product) . Your code can manipulate the intermediate model without affecting the 'real' one, and then allow code generaiton to continue.

    good luck