IlsUses
 
IlsUses
Category 
Modeling class template
Inheritance Path 
IlsViewedRel
IlsUses
Description 
Rogue Wave Server lets you declare use relations among object classes. Use relations are relations in which one particular object can be used by any number of other objects, called the users.
With Rogue Wave Server, you can define one-to-one relations, in which the user uses only one other object, and one-to-many relations, in which the user uses several objects. One-to-one use relations are declared inside the user class as instances of the class template IlsUses.
UserType and UsedType must both derive directly or transitively from IlsEntity or IlsObject. Derivation must be public.
Library 
<server>
Header File 
#include <ilserver/model.h>
Synopsis 
template <class UserType, class UsedType>
class IlsUses
{
public:
IlsUses(UserType& user,
CUsedTypePR used,
IlsRelationId identifier=IlsDefaultRelationId,
IlsActivity activity=IlsModel::GetDefaultActivity(),
IlsBoolean mandatory=Ilstrue);
 
virtual ~IlsUses();
 
IlsBoolean isMandatory();
UserType& getUser();
IlsRelationId getIdentifier();
Myself& set(CUsedTypePR);
virtual void cut(ILS_CUT_DIRECTIVE=ILS_ALL);
Myself& clear();
operator CUsedTypePR();
CUsedTypePR getValueQuietly() const;
UsedType& operator*();
IlsBoolean operator!();
UsedType* operator->();
IlsBoolean operator==(Myself& rhs);
IlsBoolean operator==(CUsedTypePR rhs);
IlsBoolean operator!=(Myself& rhs);
IlsBoolean operator!=(CUsedTypePR rhs);
IlsBoolean isModified();
UsedTypeP getOldValue();
};
Constructor 
IlsUses(UserType& user,
CUsedTypePR used,
IlsRelationId identifier=IlsDefaultRelationId,
IlsActivity activity=IlsModel::GetDefaultActivity(),
IlsBoolean mandatory=IlsTrue);
This constructor takes the following arguments:
*A reference to the user object.
*The second argument is a smart pointer to the specified used object. This argument is optional. If it is left out, then the relation will contain a null smart pointer.
*The third argument, of type IlsRelationId, represents the relation identifier. It behaves like a numeric type and is generally used to invert relations. Its default value is IlsDefaultRelationId.
*The argument activity specifies whether the relation is active or not. A relation is active if its modification sets off the recomputation of derived data members. The default value is the one returned by the member function IlsModel::GetDefaultActivity, which is ILS_INACTIVE by default.
*The argument mandatory specifies whether the relation is mandatory. For details, see the function isMandatory.
Warning: It is strongly recommended to avoid circular mandatory relations, If you do, the cut function will be called twice on the origin object cut first, which can yield unpredictable results.
Destructor 
virtual ~IlsUses();
This destructor cuts the relation.
Member Functions 
IlsBoolean isMandatory();
This function returns IlsTrue if a relation is mandatory. Otherwise, it returns IlsFalse. When a relation is mandatory, a cut applied to the target of the relation is propagated to its origin. By default, this function returns IlsTrue.
UserType& getUser();
This member function returns a reference to the user object. This function is useful especially in the case of derived relations.
IlsRelationId getIdentifier();
This function returns the relation identifier.
Myself& set(CUsedTypePR);
This member function is equivalent to an assignment. It can be used as a shortcut when you derive relations.
This function throws the following exceptions:
*IlsUpdateForbidden if the member function isUpdateAllowed returns IlsFalse for the type in which the relation is declared.
*IlsUnOwnedUse if the specified object is neither an owned object nor an entity, and if the member function IlsModel::IsIntegrityChecked returns IlsTrue.
[virtual] void cut(ILS_CUT_DIRECTIVE=ILS_ALL);
This virtual member function cuts the relation. It throws the exception IlsUpdateForbidden if the member function isUpdatedAllowed returns IlsFalse for the type in which the relation is declared.
This function can be overloaded.
Myself& clear();
This member function sets the relation to zero.
This functions throws the exception IlsUpdateForbidden if the member function isUpdateAllowed returns IlsFalse for the type in which the relation is declared.
CUsedTypePR getValueQuietly() const;
This member function provides quick access to the value of the used type. It should not be used to evaluate a derived data member or to retrieve a value when using Rogue Wave Server transactions.
Notification Member Functions
IlsBoolean isModified();
During a notification phase, this member function returns IlsTrue only if the relation has been modified since the last notification phase.
UsedTypeP getOldValue();
During a notification phase, this member function returns a smart pointer to the object that was the target of the relation before the notification phase.
Operators 
These operators let you handle relations as if they were pointers. See the class IlsSmartPointer to see what exceptions may be raised.
operator CUsedTypePR();
This operator converts the relation to a smart pointer to an object of the UsedType.
UsedType& operator*();
This operator returns a reference to the used object.
IlsBoolean operator!();
This logical not operator returns IlsTrue if the relation is null.
UsedTypeP operator->();
This dereference operator returns the target of the relation.
IlsBoolean operator==(Myself& rhs);
This operator checks whether the relation is equal to another relation.
IlsBoolean operator==(CUsedTypePR rhs);
This operator checks whether the relation is equal to the specified smart pointer.
IlsBoolean operator!=(Myself& rhs);
This operator checks whether the relation is not equal to another relation.
IlsBoolean operator!=(CUsedTypePR rhs);
This operator checks whether the relation is not equal to the specified smart pointer.
See Also 
Exceptions, IlsEntity, IlsObject, IlsOwns, IlsOwnsList, IlsUsesDynamicArray, IlsUsesFixedArray, IlsUsesList

Version 5.8
Copyright © 2014, Rogue Wave Software, Inc. All Rights Reserved.