Automatic guessing on association ends

                                        

Automatic guessing on association ends happens when C++ Developer 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 table shows the generated declaration for an association end named "assoc".

 

Association end type

Cardinality

Declaration

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;

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;

integer   

0..1

int* assoc;

1..1

int* assoc;

0..*

std::vector<int*> assoc;

1..*

std::vector<int*> assoc;

n..m

std::vector<int*> assoc;

string                  

0..1

std::string* assoc;

1..1

std::string* assoc;

0..*

std::vector<std::string*> assoc;

1..*

std::vector<std::string*> assoc;

n..m

std::vector<std::string*> assoc;

MyDatatype
isPrimitive=true                

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:   The gray cells in the above table are only provided for the sake of completeness.  However, no such models should be constructed.

 

Note 2:   Where the table states integer, this can be any basic type (integer, char, float, boolean).

 

Note 3:   As an association end is made to associate two complex classes, even primitive types are treated as complex.

 

Note 4:   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

 

Note 5:   To use a basic type (integer, boolean, etc) to type an association end, simply carry out the following steps:

1) Create an association in the explorer.  The association dialog box then appears.

              2)  Select an attribute typed by a basic type in the explorer.

              3)  Look in the "Auxiliary properties" tab of the auxiliary window.  The basic type is present.

              4) Drag this basic type into the destination of the association.