Automatic guessing on attributes

 

Automatic guessing on attributes happens when C++ Developer is generating the code for a single attribute for which the automatic generation flag is set.

 

For attributes, which in most cases are supposed to be primitive types (integer, float, char, boolean), the automatic guessing algorithm will favor declaration by value.  However, pointer declaration will be used to deal with the 0 minimum cardinality cases.

 

For automatic guessing on attributes, the relevant information is as follows:

·         the kind of the type (datatype or class)

·         cardinality

·         ordering/uniqueness tags

 

The following table shows the generated declaration for an attribute named "att".

 

Attribute type

Cardinality

Declaration

integer   

0..1

int* att;

1..1

int att;

0..*

std::vector<int> att;

1..*

std::vector<int> att;

n..m

std::vector<int> att;

string                  

0..1

std::string* att;

1..1

std::string att;

0..*

std::vector<std::string> att;  

1..*

std::vector<std::string> att;  

n..m

std::vector<std::string> att;

MyClass             

0..1

MyClass* att;

1..1

MyClass att;

0..*

std::vector<MyClass*> att;     

1..*

std::vector<MyClass*> att;     

n..m

std::vector<MyClass*> att;     

MyDatatype isPrimitive=true   

0..1

MyDatatype* att;

1..1

MyDatatype att;

0..*

std::vector<MyDatatype> att;

1..*

std::vector<MyDatatype> att;

n..m

std::vector<MyDatatype> att;

MyDatatype    
isPrimitive=false  

0..1

MyDatatype* att;

 

1..1

MyDatatype att;

0..*

std::vector<MyDatatype*> att;  

1..*

std::vector<MyDatatype*> att;  

n..m

std::vector<MyDatatype*> att;  

 

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

 

Note 2:   The std::vector is replaced by:

              -std::hash_set when the "Is unique" option is set on the attribute
-std::set when both the "Is ordered" and "Is unique" options are set on the attribute

 

Note 3:   An element typed undefined is generated as void*.