Generating accessors for attributes¶
These are the accessors generated by C++ Designer when the “Create accessors”
command is activated. These accessors are created in the model, meaning they
are created in the form of modeled methods. They are automatically decorated
for subsequent C++ generation.
Card | Declaration | Get accessor | Set accessor |
0..1 | int* att; | const int* getAtt() const | void setAtt(int* value) |
1..1 | int att; | int getAtt() const | void setAtt(int value) |
0..* | std::vector<int> att; | std::vector<int>& getAtt() const | |
1..* | std::vector<int> att; | std::vector<int>& getAtt() const | |
n..m | std::vector<int> att; | std::vector<int>& getAtt() const | |
Card | Declaration | Get accessor | Set accessor |
0..1 | std::string* att; | std::string* getAtt() const | void setAtt(std::string* value) |
1..1 | std::string att; | std::string getAtt() const | void setAtt(std::string value) |
0..* | std::vector<std::string> att; | std::vector<std::string>& getAtt() const | |
1..* | std::vector<std::string> att; | std::vector<std::string>& getAtt() const | |
n..m | std::vector<std::string> att; | std::vector<std::string>& getAtt() const | |
Card | Declaration | Get accessor | Set accessor |
0..1 | MyClass* att; | MyClass* getAtt() const | void setAtt(MyClass* value) |
1..1 | MyClass att; | MyClass& getAtt() const | void setAtt(MyClass value) |
0..* | std::vector<MyClass*> att; | std::vector<MyClass*>& getAtt() const | |
1..* | std::vector<MyClass*> att; | std::vector<MyClass*>& getAtt() const | |
n..m | std::vector<MyClass*> att; | std::vector<MyClass*>& getAtt() const | |
- Attribut type: MyDatatype (isPrimitive=true)
Card | Declaration | Get accessor | Set accessor |
0..1 | MyDatatype* att; | MyDatatype* getAtt() const | void setAtt(MyDatatype* value) |
1..1 | MyDatatype att; | MyDatatype getAtt() const | void setAtt(MyDatatype value) |
0..* | std::vector<MyDatatype> att; | std::vector<MyDatatype>& getAtt() const | |
1..* | std::vector<MyDatatype> att; | std::vector<MyDatatype>& getAtt() const | |
n..m | std::vector<MyDatatype> att; | std::vector<MyDatatype>& getAtt() const | |
- Attribut type: MyDatatype (isPrimitive=false)
Card | Declaration | Get accessor | Set accessor |
0..1 | MyDatatype* att; | MyDatatype* getAtt() const | void setAtt(MyDatatype* value) |
1..1 | MyDatatype att; | MyDatatype& getAtt() const | void setAtt(MyDatatype value) |
0..* | std::vector<MyDatatype*> att; | std::vector<MyDatatype*>& getAtt() const | |
1..* | std::vector<MyDatatype*> att; | std::vector<MyDatatype*>& getAtt() const | |
n..m | std::vector<MyDatatype*> att; | std::vector<MyDatatype*>& getAtt() const | |
Note 1: Where the table states integer, this can be any basic type (integer, char, float, boolean).
Note 2: Accessors with maximum cardinality “*” return a reference to the internal collection, so the user can directly manipulate the
container contents using the accessors specific to the container type. There are no “set” accessors for these cases and we recommend that you use the “get”
accessor and the proper container API on the returned value.