IlsOwnsDynamicArray
Category
Modeling class template
Inheritance Path
IlsViewedRel➥ IlsOwnsDynamicArray Description
Rogue Wave Server lets you declare dynamic arrays of ownership relations.
Such relations are declared inside the owner class as instances of the class template IlsOwnsDynamicArray.
OwnerType must derive directly or transitively from
IlsEntity or
IlsObject.
OwnedType must derive directly or transitively from
IlsObject. Derivation must be public.
Library
Synopsis
template<class OwnerType, class OwnedType>
class IlsOwnsDynamicArray
{
public:
(OwnerType& owner,
unsigned int size=0,
IlsRelationId identifier=IlsDefaultRelationId,
IlsActivity activity=IlsModel::GetDefaultActivity(),
IlsBoolean mandatory=IlsFalse);
Myself&
renew (unsigned int=0);
virtual void
cut(unsigned int rank, ILS_CUT_DIRECTIVE=ILS_ALL);
};
Constructor
IlsOwnsDynamicArray
(OwnerType& owner,
unsigned int size=0,
IlsRelationId identifier=IlsDefaultRelationId,
IlsActivity activity=IlsModel::GetDefaultActivity(),
IlsBoolean mandatory=IlsFalse);
This constructor takes the following arguments:
The first argument is a reference to the owner-object.
The second argument specifies the maximum size of the array.
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 indicates whether the relation is mandatory. For details, see the member function
isMandatory documented below.
Destructor
virtual ~IlsOwnsDynamicArray()
This destructor breaks all relations stored in the array.
Member Functions
IlsActivity getActivity() const;
This member function returns
ILS_ACTIVE if the relation has been set as active. Otherwise, it returns
ILS_INACTIVE. For details, see the constructor.
unsigned int getSize() const;
This member function lets you get the size of the relation array at a given time.
Myself& renew (unsigned int=0);
This member function lets you allocate or create a new array with a specified size. Its takes the new size of the array as its argument. By default, the value of the argument is zero. Smart pointers to objects contained in the old array are erased and replaced with null smart pointers in the new array.
IlsBoolean isMandatory();
This member function returns IlsTrue if the 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, the function returns IlsFalse for a relation array.
OwnerType& getOwner();
This member function returns the owner of the relation.
IlsRelationId getIdentifier() const;
This member function returns the relation identifier.
[virtual] void cut(unsigned int rank, ILS_CUT_DIRECTIVE=ILS_ALL);
This virtual member function is called when a cut is applied to the target of the relation.
Myself& clear();
This function sets all the array elements to zero.
This member function throws the exception
IlsUpdateForbidden if the member 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 if the array-relation has been modified since the last notification phase, that is, if one of these events has occurred:
Re-allocation of the array-relation;
Addition of one or more elements to the array-relation;
Removal of one or more elements from the array-relation.
int* getAdded(int& how_many);
During a notification phase, this member function returns an arrays of indices corresponding to the elements that have been added to the array since the last notification phase. It returns an empty array if no element has been added to the array. The argument how_many accepts the size of the array as a return value. You must explicitly destroy this array when you no longer need it. To do so, use delete with square brackets [].
OwnedType** getRemoved(int& how_many);
During a notification phase, this member function returns an array of pointers to the objects that have been removed from the array since the last notification phase. It returns an empty array if no element has been removed from the array. The argument how_many gives the size of the array as a return value. You must explicitly destroy this array when you no longer need it. To do so, use delete with square brackets [].
Operators
Partial& operator[](int);
This operator returns the i-th array element. Partial can be assigned the type OwnedTypeP.
If
i is greater than the size specified for the array (minus 1), the exception
IlsSizeViolation is thrown.
See Also
Version 5.8
Copyright © 2014, Rogue Wave Software, Inc. All Rights Reserved.