IlsUsesDynamicArray
Category
Modeling class template
Inheritance Path
IlsViewedRel➥ IlsUsesDynamicArray Description
Rogue Wave Server lets you declare dynamic arrays of use relations. Such relations are declared within the user class as instances of the class template IlsUsesDynamicArray.
UserType and
UsedType must both derive directly or transitively from
IlsEntity or
IlsObject. Derivation must be public.
Library
Synopsis
template<class UserType, class UsedType>
class IlsUsesDynamicArray
{
public:
(UserType& user,
unsigned int int size=0,
IlsRelationId identifier=IlsDefaultRelationId,
IlsActivity activity=IlsModel::GetDefaultActivity(),
IlsBoolean mandatory=IlsFalse);
Myself&
renew(unsigned int=0);
virtual void
cut(unsigned int rank);
};
Constructor
IlsUsesDynamicArray
(UserType& user,
unsigned int 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 user object.
The second argument specifies the maximum size of the array.
The third argument is of type
IlsRelationId. It represents the relation identifier and behaves like a numeric type. Its default value is
IlsDefaultRelationId. It is generally used to invert relations.
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 member function
isMandatory.
Destructor
virtual ~IlsUsesDynamicArray();
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.
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, this function returns IlsFalse.
unsigned int getSize() const;
This member function lets you get the size of the 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. It takes the new array size as its argument with
0 as the default value. Smart pointers to objects contained in the old array are erased and replaced with null smart pointers in the new array. This function throws the exception
IlsUpdateForbidden if the function
isUpdateAllowed returns
IlsFalse for the type in which the relation is declared.
UserType& getUser();
This member function returns the user of the array-relation.
IlsRelationId getIdentifier() const;
This member function returns the relation identifier.
[virtual] void cut(unsigned int rank);
This virtual member function is called when a cut is applied to the target of the relation.
Myself& clear();
This member function sets all the array elements 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 Member Functions
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 the events listed below 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 array 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 [].
UsedType** 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 i);
This operator returns the i-th array element. Partial can be assigned the type UsedTypeP.
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.