Collection Class mapping for C++ (C++ code)
This topic explains how collection classes are reverse engineered through Reverser.
When reverse engineering an attribute whose data type is a collection class, the attribute can be reverse engineered as an Attribute or a Role. A collection class' attribute is reverse engineered as a Role only if the collection class is set up in the Cppgen.ini file to be reverse engineered as a Role, and then only if the appropriate parameter is referencing a Class that is being reverse engineered.
You can use a text editor, such as Notepad, to change the Cppgen.ini file. The Cppgen.ini file resides in the PTC Modeler\Modeler\System\CppGen folder.
The Cppgen.ini file includes the following section.
[Collection Classes]
vector=1
list=1
deque=1
map=2
set=1
multimap=2
multiset=1
hash_set=1
hash_multiset=1
hash_map=2
hash_multimap=2
Each entry is a commonly used collection class from the C++ Standard Template Library. The value associated with each collection class specifies the parameter that references a Class. If the specified parameter references a Class that is being reverse engineered, the attribute is reverse engineered as a Role rather than an Attribute.
To reverse engineer a role to the template class itself, for example, if the template class is not a collection class, add an entry similar to this:non_collection_class=0
The zero tells the reverse engineering tool to create a role to 'non_collection_class', not any parameters it may have.
If your code files include collection classes that are not listed in the [Collection Classes] section of the Cppgen.ini file and you want attributes of that type to be reverse engineered as Roles in the model, you must add those collection classes to the [Collection Classes] section.
Examples:
The following examples demonstrate how collection classes are reverse engineered.
vector<Foo> myFoos;
In this example, myFoos is reverse engineered as a Role to class Foo, because vector is in the [Collection Classes] section and parameter 1 is a class that is being reverse engineered.
vector<int> myInts;
In this example, myInts is reverse engineered as an Attribute, because although vector is in the [Collection Classes] section, int is not a class.
my_collection<Foo> myFoos;
In this example, myFoos is reverse engineered as an Attribute, because although Foo is a class, my_collection does not appear in the [Collection Classes] section.
map<string, Bar> myBars;
In this example, myBars is reverse engineered as a Role to class Bar, because map is in the [Collection Classes] section and parameter 2 is a class that is being reverse engineered.