Setting system arguments for UML-to-C++ transformations

You can specify system arguments for the UML-to-C++ transformation in the eclipse.ini file, which enables you to specify transformation behavior that is not contained in the transformation configuration file. For example, you can specify alternate file name extensions and change the display order, based on visibility, of generated attributes and operations.

About this task

To specify system arguments for the UML-to-C++ transformation:

Procedure

  1. Open the eclipse.ini file in a text editor. The eclipse.ini file is located in the directory that you specified as the installation root when you installed the product.
  2. Add the transformation behavior preferences to the end of the file. Specify each preference on a unique line after the other existing workbench arguments in the file. The following table lists the behaviors that you can configure and the arguments that you must add to the eclipse.ini file.
    Action System argument Default transformation behavior
    Display attributes and operations in the following order: Public, Protected, Private -DVISIBILITY_ORDER=true If you do not specify this system argument, the generated code lists attributes and operations in the following order: Private, Protected, Public.
    Exclude relative path information in #include directives -DEXCLUDE_PATH_FOR_INCLUDES=true If you do not specify this system argument, the transformation generates #include directives that specify relative path information.
    Generate the typename keyword when declaring class templates with type parameters, for example, template <typename identifier> class_declaration -DTYPENAME_TEMPLATES=true If you do not specify this system argument, when you run the transformation on a model that contains a template class with a template parameter that is of type class, the generated declaration contains the class keyword.

    Consider the following example:

    This image shows a UML template class called TemplateClass1, which has a template parameter called T1, of type class.

    By default, the transformation generates the following declaration in TemplateClass1.h:
    template <class Parameter1>
    class Class1
    {
    
        //Begin section for Class1
        //TODO: Add attributes that you want preserved
        //End section for Class1
        public:
    
    
            //@uml.annotationsderived_abstraction="platform:/resource/Miscellaneous%20Models/source.emx#_hFn-0GaLEdyC-b6mj80KQA"
            //@generated "UML to C++ (com.ibm.xtools.transform.uml2.cpp.CPPTransformation)"
            int Operation1()
            {
                //TODO Auto-generated method stub
                return 0;
            }
    
    };  //end class Class1
    </class>
    If you specify -DTYPENAME_TEMPLATES=true, the transformation generates the following declaration in TemplateClass1.h:
    template <typename Parameter1>
    class Class1
    {
    
        //Begin section for Class1
        //TODO: Add attributes that you want preserved
        //End section for Class1
        public:
    
    
            //@uml.annotationsderived_abstraction="platform:/resource/Miscellaneous%20Models/source.emx#_hFn-0GaLEdyC-b6mj80KQA"
            //@generated "UML to C++ (com.ibm.xtools.transform.uml2.cpp.CPPTransformation)"
            int Operation1()
            {
                //TODO Auto-generated method stub
                return 0;
            }
    
    };  //end class Class1</typename>
    Generate inline function code in a header file -DINLINE_HEADER=true If you do not specify this system argument, the transformation generates the code for inline functions in the C++ body file.
    Specify alternate file name extensions for C++ body files -DBODY_FILE_EXTENSION=.<file name extension>
    For example, to generate C++ body files that have .cc as a file name extension, specify -DBODY_FILE_EXTENSION=.cc.
    Note: If you apply the «cpp_properties» stereotype to a source model element, the value of the bodyFileExtension property overrides the value that you specify in the eclipse.ini file.
    If you do not specify this system argument, the transformation generates C++ body files that have .cpp as a file name extension.
  3. Click File > Save.
  4. Restart Eclipse, and specify the -clean option.

Feedback