Types of to‑many links are as follows:
Appropriate accessor and mutator operations are generated for each type of link, depending on the container used to implement it. The defaults for implementing relations are modifiable through the properties of the role.
By default, ordered links to more than one object are implemented as an RiCList. A to‑many link is made ordered by setting the CG::Relation::Ordered property to Checked. This ordering includes relations where the multiplicity is known (bounded ordered relations) and where the multiplicity is not known (unbounded ordered relations).
By default, unordered links to more than one object are implemented as an RiCCollection. A to‑many link is made unordered by setting the Ordered property to Cleared. This linking includes relations where the multiplicity is known (bounded unordered relations) and where the multiplicity is not known (unbounded unordered relations).
Links to subobjects are implemented as an embedded data member if the multiplicity of the subobject is one (embedded scalar relation), or as an array if the multiplicity of the subobject has a numeric value greater than one (embedded fixed relation).
For example, the HomeHeatingSystem object has one subobject called itsFurnace and three subobjects called itsRoom, all embedded as components. In this case, theFurnace has an embedded scalar relation and theRooms has an embedded fixed relation to HomeHeatingSystem. These relations are implemented as follows:
struct HomeHeatingSystem {
/*** User implicit entries ***/
struct Furnace theFurnace;
struct Room theRooms[3];
};
You can achieve the same effect by setting the CG::Relation::Implementation property to Scalar for a scalar relation or Fixed for a fixed relation. These types of relation implementations are only used under two conditions:
By default, to‑many links with a fixed multiplicity are implemented as an RiCCollection.
By default, to‑many links where a qualifier is specified on the link are implemented as an RiCMap.
A random access link is a relation that has been enhanced to provide random access to the items in the container. You can give a to‑many link random access by setting the C_CG::Relation::GetAt property for the role to Checked. The C_CG::Relation::GetAtGenerate property must also be set to Checked. This setting generates an accessor for the role that uses an appropriate getAt() method for the container. The $index keyword is passed as a parameter to the getAt() method to access a particular element inside the container. The default value for $index is int i.
For example, the GetAt property for a bounded ordered relation has the following value:
RiCList_getAt(&$me$cname, $index)
Setting the GetAt property for theRooms to Checked causes the following accessor to be generated in the HomeHeatingSystem to allow it to access a particular Room:
struct Room * HomeHeatingSystem_getTheRooms(
const HomeHeatingSystem* const me, int i) {
return RiCList_getAt(&me->theRooms, i);
}