Modeling Services > Context-Sensitive Features > Redefining the cut Function > Mandatory Relations
 
Mandatory Relations
A cut applied to the target of a mandatory relation is propagated to the origin. If the relation is not mandatory, the relation is broken but the cut is not propagated to the origin.
To specify whether a relation is mandatory, you have to pass an additional Boolean argument to the constructor of that relation. By default, this argument is IlsTrue for a one-to-one relation and IlsFalse for a one-to-many relation.
In the following code, the Car/Wheel relation is set as non-mandatory in the constructor of Car.
// ...
class Car:
public IlsObject
{
public:
   Car();
   IlsOwns<Car,Wheel>
      frontRightWheel, frontLeftWheel,
      rearRightWheel, rearLeftWheel;
};
 
Car::Car(
   WheelP frw,
   WheelP flw,
   WheelP rrw,
   WheelP rlw
):
frontRightWheel(*this,frw,IlsDefaultRelationId,ILS_INACTIVE,IlsFalse,
frontLeftWheel(*this,flw,IlsDefaultRelationId,ILS_INACTIVE,IlsFalse),
rearRightWheel(*this,rrw,IlsDefaultRelationId,ILS_INACTIVE,IlsFalse),
rearLeftWheel(*this,rlw,IlsDefaultRelationId,ILS_INACTIVE,IlsFalse)
{}
When a cut operation is performed on a wheel, the car is not cut. The relation is set to a null smart pointer. To know whether a relation is mandatory, you can use the member function isMandatory. For more information, see the Rogue Wave® Server Reference Manual.

Version 6.3
Copyright © 2018, Rogue Wave Software, Inc. All Rights Reserved.