When you configure the transformation to create derived relationships between source model elements, the transformation adds a unique identifier to each transformed element in the generated source code.
| Model element | Change | Impact on previously generated code when you rerun the transformation |
|---|---|---|
| Attribute | Rename or move | If you delete the @generated tag of the attribute, no
changes are made to the attribute. No changes are made to its getter and setter
methods, if generated. If you do not delete the @generated tag of the attribute,
the following actions occur:
|
| Class or interface | Rename | If you delete the @generated tag of the class or interface,
the file for the class is not renamed. If you do not delete the @generated
tag, the following actions occur:
|
| Top-level class or interface | Move | If you delete the @generated tag of the top-level class
or interface, the file for the class does not change. If you do not delete
the @generated tag, the following actions occur:
|
| Operation | Rename, move, or modify a return type or signature | If you delete the @generated tag of the operation, no
changes are made to the operation. If you do not delete the @generated
tag, the following actions occur:
|
| Package | Rename or move | The files in the original generated folder are moved
to the new folder. Obsolete folders and files are deleted if the obsolete file deletion option is selected in the transformation configuration. |
| Package with «cpp_namespace» applied | Rename the NamespaceName property | The namespace is renamed in all generated source files. Code changes that refer to the original namespace are not refactored. |
| Rename the package | The code is refactored and moved to the renamed package because the package does not have a unique identifier. |
The following example shows the changes to the code when you rerun the transformation, depending on the existence of unique identifiers and the @generated tag.
Assume that the UML source model in this example contains the following class:

| Class1.h | Class1.cpp |
|---|---|
//@uml.annotationsderived_abstraction="platform:/resource/Bug-Fixes/GUIDs.emx#_0NWVMJy6EdueYKrofslx4A"
//@generated "UML to C++ (com.ibm.xtools.transform.uml2.cpp.CPPTransformation)"
class Class1
{
//Begin section for Class1
//TODO: Add attributes that you want preserved
//End section for Class1
private:
//@generated "UML to C++ (com.ibm.xtools.transform.uml2.cpp.CPPTransformation)"
//@uml.annotationsderived_abstraction="platform:/resource/Bug-Fixes/GUIDs.emx#_0NWVMJy6EdueYKrofslw3S"
int attribute1;
public:
//@generated "UML to C++ (com.ibm.xtools.transform.uml2.cpp.CPPTransformation)"
//@uml.annotationsderived_abstraction="platform:/resource/Bug-Fixes/GUIDs.emx#_0NWVMJy6EdueYKrofsly5D"
int Operation1(int Parameter1);
}; //end class Class1
|
#include "Class1.h"
//Begin section for file Class1.cpp
//TODO: Add definitions that you want preserved
//End section for file Class1.cpp
//@generated "UML to C++ (com.ibm.xtools.transform.uml2.cpp.CPPTransformation)"
int Class1::Operation1(int Parameter1)
{
//TODO Auto-generated method stub
return 0;
}
|
int Class1::Operation1(int Parameter1)
{
return Parameter1;
}
| Code with unique identifiers |
|---|
| @generated tag not deleted |
The code illustrates the following changes:
Class1.h: //@uml.annotationsderived_abstraction="platform:/resource/Bug-Fixes/GUIDs.emx#_0NWVMJy6EdueYKrofslx4A"
//@generated "UML to C++ (com.ibm.xtools.transform.uml2.cpp.CPPTransformation)"
class Class1
{
//Begin section for Class1
//TODO: Add attributes that you want preserved
//End section for Class1
private:
//@generated "UML to C++ (com.ibm.xtools.transform.uml2.cpp.CPPTransformation)"
//@uml.annotationsderived_abstraction="platform:/resource/Bug-Fixes/GUIDs.emx#_0NWVMJy6EdueYKrofslw3S"
int attribute1;
public:
//@generated "UML to C++ (com.ibm.xtools.transform.uml2.cpp.CPPTransformation)"
//@uml.annotationsderived_abstraction="platform:/resource/Bug-Fixes/GUIDs.emx#_0NWVMJy6EdueYKrofsly5D"
int Operation2(int Parameter1);
}; //end class Class1
Class1.cpp:
#include "Class1.h"
//Begin section for file Class1.cpp
//TODO: Add definitions that you want preserved
//End section for file Class1.cpp
//@generated "UML to C++ (com.ibm.xtools.transform.uml2.cpp.CPPTransformation)"
int Class1::Operation2(int Parameter1)
{
return Parameter1;
}
|
| @generated tag deleted from Class1.h or Class1.cpp |
| The transformation uses unique identifiers to determine
that Operation1 was renamed to Operation2 in the model, but because you deleted
the @generated tag of the method, the transformation preserves the changes
to Operation1. Therefore, Operation1 does not change in Class1.h or Class1.cpp,
and the transformation does not generate a method called Operation2. Class1.h:
//@uml.annotationsderived_abstraction="platform:/resource/Bug-Fixes/GUIDs.emx#_0NWVMJy6EdueYKrofslx4A"
//@generated "UML to C++ (com.ibm.xtools.transform.uml2.cpp.CPPTransformation)"
class Class1
{
//Begin section for Class1
//TODO: Add attributes that you want preserved
//End section for Class1
private:
//@generated "UML to C++ (com.ibm.xtools.transform.uml2.cpp.CPPTransformation)"
//@uml.annotationsderived_abstraction="platform:/resource/Bug-Fixes/GUIDs.emx#_0NWVMJy6EdueYKrofslw3S"
int attribute1;
public:
//@uml.annotationsderived_abstraction="platform:/resource/Bug-Fixes/GUIDs.emx#_0NWVMJy6EdueYKrofsly5D"
int Operation1(int Parameter1);
}; //end class Class1
Class1.cpp:
#include "Class1.h"
//Begin section for file Class1.cpp
//TODO: Add definitions that you want preserved
//End section for file Class1.cpp
int Class1::Operation1(int Parameter1)
{
return Parameter1;
}
|
The following table shows the code that the transformation generates when you rerun a transformation that is not configured to generate derived relationships. Without unique identifiers, the transformation uses fully qualified names and method signatures to link model elements to source code elements; also, refactoring is not supported.
| Code without unique identifiers |
|---|
| @generated tag not deleted |
The code illustrates the following changes:
Class1.h:
#ifndef CLASS1_H
#define CLASS1_H
//Begin section for file Class1.h
//TODO: Add definitions that you want preserved
//End section for file Class1.h
//@generated "UML to C++ (com.ibm.xtools.transform.uml2.cpp.CPPTransformation)"
class Class1
{
//Begin section for Class1
//TODO: Add attributes that you want preserved
//End section for Class1
private:
//@generated "UML to C++ (com.ibm.xtools.transform.uml2.cpp.CPPTransformation)"
int attribute1;
public:
//@generated "UML to C++ (com.ibm.xtools.transform.uml2.cpp.CPPTransformation)"
int Operation2(int Parameter1);
}; //end class Class1
Class1.cpp:
//Begin section for file Class1.cpp
//TODO: Add definitions that you want preserved
//End section for file Class1.cpp
//@generated "UML to C++ (com.ibm.xtools.transform.uml2.cpp.CPPTransformation)"
int Class1::Operation2(int Parameter1)
{
//TODO Auto-generated method stub
return 0;
}
|
| @generated tag deleted from Class1.h or Class1.cpp |
| Without unique identifiers, the transformation determines
that Operation2 is a new method. The code illustrates the following changes:
Class1.h:
#ifndef CLASS1_H
#define CLASS1_H
//Begin section for file Class1.h
//TODO: Add definitions that you want preserved
//End section for file Class1.h
//@generated "UML to C++ (com.ibm.xtools.transform.uml2.cpp.CPPTransformation)"
class Class1
{
//Begin section for Class1
//TODO: Add attributes that you want preserved
//End section for Class1
private:
//@generated "UML to C++ (com.ibm.xtools.transform.uml2.cpp.CPPTransformation)"
int attribute1;
public:
int Operation1(int Parameter1);
//@generated "UML to C++ (com.ibm.xtools.transform.uml2.cpp.CPPTransformation)"
int Operation2(int Parameter1);
}; //end class Class1
#endif
Class1.cpp:
#include "Class1.h"
//Begin section for file Class1.cpp
//TODO: Add definitions that you want preserved
//End section for file Class1.cpp
int Class1::Operation1(int Parameter1)
{
return Parameter1;
}
//@generated "UML to C++ (com.ibm.xtools.transform.uml2.cpp.CPPTransformation)"
int Class1::Operation2(int Parameter1)
{
//TODO Auto-generated method stub
return 0;
}
|