IlsOwns
 
IlsOwns
Category 
Modeling class template
Inheritance Path 
IlsViewedRel
IlsOwns
Description 
Rogue Wave Server lets you declare ownership relations among object classes. Ownership relations are relations in which one particular object is owned by at most one other object, called the owner. With Rogue Wave Server, you can define one-to-one relations, in which the owner owns only one other object, and one-to-many relations, in which the owner owns several objects. One-to-one ownership relations are declared inside the owner class as instances of the class template IlsOwns.
The OwnerType must derive directly or transitively from IlsObject or IlsEntity. The OwnedType must derive directly or transitively from IlsObject. Derivation must be public.
Library 
<server>
Header File 
#include <ilserver/model.h>
Synopsis 
template <class OwnerType, class OwnedType>
class IlsOwns
{
public:
IlsOwns(OwnerType& owner,
COwnedTypePR owned=(OwnedType*)0,
IlsRelationId identifier=IlsDefaultRelationId,
IlsActivity activity=IlsModel::GetDefaultActivity();
IlsBoolean mandatory=IlsTrue);
virtual ~IlsOwns();
IlsBoolean isMandatory();
OwnerType& getOwner();
IlsRelationId getIdentifier();
COwnedTypePR getValueQuietly() const;
Myself& set(COwnedTypePR);
virtual void cut(ILS_CUT_DIRECTIVE=ILS_ALL);
Myself& clear();
operator COwnedTypePR();
OwnedType& operator*();
IlsBoolean operator!();
OwnedType* operator->();
IlsBoolean operator==(Myself& rhs);
IlsBoolean operator==(COwnedTypePR rhs);
IlsBoolean operator!=(Myself& rhs);
IlsBoolean operator!=(COwnedTypePR rhs);
IlsBoolean isModified();
OwnedTypeP getOldValue();
};
Constructor 
IlsOwns(OwnerType& owner,
COwnedTypePR owned=(OwnedType*)0,
IlsRelationId identifier=IlsDefaultRelationId,
IlsActivity activity=IlsModel::GetDefaultActivity(),
IlsBoolean mandatory=IlsTrue);
This constructor takes the following arguments:
*The first argument is a reference to the owner object.
*The second argument is a smart pointer to the owned object specified. 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 function IlsModel::GetDefaultActivity, which is ILS_INACTIVE by default.
*The last argument specifies whether the relation is mandatory. For details, see the function isMandatory documented below.
Destructor 
virtual ~IlsOwns();
This destructor cuts the relation.
Member Functions 
IlsBoolean isMandatory();
This member function returns IlsTrue if a relation is mandatory. Otherwise, it returns IlsFalse. When a relation is mandatory, a cut applied to the target of this relation is propagated to its origin. By default, the function returns IlsTrue.
OwnerType& getOwner();
This member function returns a reference to the owner object. This function is useful especially in the case of derived relations.
IlsRelationId getIdentifier();
This member function returns the relation identifier.
COwnedTypePR getValueQuietly() const;
This member function provides quick access to the value of the owned type. It should not be used to evaluate a derived data member or to retrieve a value when using Rogue Wave Server transactions.
Myself& set(COwnedTypePR);
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.
*IlsOwnershipCycle if cycles are detected among ownership relations.
*IlsAlreadyInserted if the supplied object is already owned.
[virtual] void cut(ILS_CUT_DIRECTIVE=ILS_ALL);
This virtual member function breaks the relation. The exception IlsUpdateForbidden is thrown if the function isUpdateAllowed 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 member function throws the exception IlsUpdateForbidden if the function isUpdateAllowed returns IlsFalse for the type in which the relation is declared.
Notification
IlsBoolean isModified();
During a notification phase, this member function returns IlsTrue only if the relation has been modified since the last notification phase.
OwnedTypeP 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 use ownership relations as if they were pointers. See the class IlsSmartPointer to see what exceptions may be raised.
operator COwnedTypePR();
This operator converts the relation to a smart pointer to an object of the OwnedType.
OwnedType& operator*();
This operator returns a reference to the owned object.
IlsBoolean operator!();
This logical not operator returns IlsTrue if the relation is null.
OwnedType* 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==(COwnedTypePR 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!=(COwnedTypePR rhs);
This operator checks whether the relation is not equal to the specified smart pointer.
See Also 
Exceptions, IlsEntity, IlsObject, IlsOwnsList, IlsOwnsDynamicArray, IlsOwnsFixedArray, IlsOwnsSet, IlsUses, IlsUsesList, IlsUsesSet

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