Automatic guessing on association ends happens when Cxx Designer is generating the code for an association end and when the automatic generation flag is set.
Association ends point to classes, therefore the automatic guessing algorithm will favor pointer declaration of objects and will avoid passing any object by value for performance reasons.
For an association end, the relevant information is as follows:
-
cardinality
-
ordering/uniqueness
The following list shows the generated declaration for an association end named "assoc".
Association end type: MyClass
-
0..1:
MyClass* assoc;
-
1..1:
MyClass* assoc;
-
0..*:
std::vector<MyClass*> assoc;
-
1..*:
std::vector<MyClass*> assoc;
-
n..m:
std::vector<MyClass*> assoc;
Association end type: MyDatatype isPrimitive=false
-
0..1:
MyDatatype* assoc;
-
1..1:
MyDatatype* assoc;
-
0..*:
std::vector<MyDatatype*> assoc;
-
1..*:
std::vector<MyDatatype*> assoc;
-
n..m:
std::vector<MyDatatype*> assoc;
Note 1: As an association end is made to associate two complex classes, even primitive types are treated as complex.
Note 2: The std::vector is replaced by:
-
std::hash_set when the "Is unique" option is set on the association end
-
std::set when both the "Is ordered" and "Is unique" options are set on the association end