Automatic guessing on parameters

 

Automatic guessing on parameters

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

 

For parameters, the automatic guessing algorithm selects the best way of passing a parameter, based on good practices:

·         Basic types by value

·         Complex types by const reference or pointers

 

The C++ Developer generator also takes care of the parameter passing mode (In or InOut) in order to further optimize the generated code.

 

 

Automatic guessing on "In" parameters

The following table shows the generated declaration for a parameter named "param".  Please note that the use of const values is favored due to the "In" mode.

 

Parameter type

Cardinality

Declaration

integer   

0..1

int* param

1..1

int param

0..*

const std::vector<int>& param

1..*

const std::vector<int>& param

n..m

const std::vector<int>& param

string                  

0..1

const std::string* param

1..1

const std::string& param

0..*

const std::vector<std::string>& param

1..*

const std::vector<std::string>& param

n..m

const std::vector<std::string>& param

MyClass             

0..1

const MyClass* param

1..1

const MyClass& param

0..*

const std::vector<MyClass*>& param

1..*

const std::vector<MyClass*>& param

n..m

const std::vector<MyClass*>& param

MyDatatype    

isPrimitive=true  

0..1

MyDatatype* param

1..1

MyDatatype param

 

0..*

const std::vector<MyDatatype>& param

1..*

const std::vector<MyDatatype>& param

n..m

const std::vector<MyDatatype>& param

MyDatatype    

isPrimitive=false  

0..1

const MyDatatype* param

1..1

const MyDatatype& param

0..*

const std::vector<MyDatatype*>& param

1..*

const std::vector<MyDatatype*>& param

n..m

const std::vector<MyDatatype*>& param

 

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

 

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

 

 

Automatic guessing on "InOut" parameters

The following table shows the generated declaration for a parameter named "param".  Please note that no const values are used due to the "InOut" mode.

 

Parameter type

Cardinality

Declaration

integer   

0..1

int* param

1..1

int& param

0..*

std::vector<int>& param

1..*

std::vector<int>& param

n..m

std::vector<int>& param

string                  

0..1

std::string* param

1..1

std::string& param

0..*

std::vector<std::string>& param

1..*

std::vector<std::string>& param

n..m

std::vector<std::string>& param

MyClass             

0..1

MyClass* param

1..1

MyClass& param

0..*

std::vector<MyClass*>& param

1..*

std::vector<MyClass*>& param

n..m

std::vector<MyClass*>& param

MyDatatype
isPrimitive=true                  

0..1

MyDatatype* param

1..1

MyDatatype& param

0..*

std::vector<MyDatatype>& param

1..*

std::vector<MyDatatype>& param

n..m

std::vector<MyDatatype>& param

MyDatatype    
isPrimitive=false      

0..1

MyDatatype* param

1..1

MyDatatype& param

0..*

std::vector<MyDatatype*>& param

1..*

std::vector<MyDatatype*>& param

n..m

std::vector<MyDatatype*>& param

 

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

 

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