One-to-many ownership relation organized as list. More...
#include <ilserver/model.h>
Public Types | |
typedef IlsListRelationConstIterator< Myself > | ConstIterator |
Const iterator for the list. | |
typedef IlsSmartDoublyLinkedList< OwnedTypeP, OwnedTypeP, IlsBasicListKeyManager< OwnedTypeP > > | Initial |
Class to pass as parameter for initializing the content of the list in its constructor. | |
typedef IlsListRelationIterator< Myself > | Iterator |
Non const iterator for the list. | |
typedef IlsOwnsList< OwnerType, OwnedType > | Myself |
Myself is the type of the instantiated template class. | |
typedef IlsPartial< OwnerType, OwnedType, Myself > | Partial |
This class is an intermediate class that stores list items. | |
typedef IlsListRelationPosition< Myself > | Position |
This class sets en iterator to a given position. | |
Public Member Functions | |
IlsOwnsList (OwnerType &owner, IlsRelationId identifier=IlsDefaultRelationId, IlsActivity activity=IlsModel::GetDefaultActivity(), IlsCardinality mincard=0, IlsCardinality maxcard=ILS_UNLIMITED_MAXCARD, Initial &targets=(*new Initial()), IlsBoolean check_card=IlsTrue) | |
Constructor. More... | |
virtual | ~IlsOwnsList () |
This destructor breaks all relations in the list. | |
Myself & | clear () |
Myself & | cons (COwnedTypePR) |
virtual void | cut (Partial &, ILS_CUT_DIRECTIVE d=ILS_ALL) |
IlsActivity | getActivity () const |
OwnedType ** | getAdded (int &) |
During a notification phase, this member function returns an array of pointers to the items that have been added to the list since the last notification phase. More... | |
COwnedTypePR | getFirst () |
virtual IlsViewed * | getIdentifiedElement (const IlsString &id) const |
This virtual member function is used to retrieve an identified object from the relation. More... | |
COwnedTypePR | getLast () |
OwnerType & | getOwner () const |
OwnedType ** | getRemoved (int &) |
During a notification phase, this member function returns an array of pointers to the items that have been removed from the list since the last notification phase. More... | |
virtual IlsBoolean | hasElement (IlsViewed &) const |
This virtual member function returns IlsTrue if the element is a target of the relation or IlsFalse otherwise. | |
IlsBoolean | isIn (COwnedTypePR e) |
Returns IlsTrue if the object pointed to belongs to the list. | |
Myself & | operator<< (COwnedTypePR newe) |
Adds an item to the list. More... | |
Myself & | operator>> (COwnedTypePR olde) |
Removes an item from the list. More... | |
COwnedTypePR | operator[] (int i) const |
Returns the i -th list item. | |
Myself & | remove (COwnedTypePR olde, ILS_CUT_DIRECTIVE d=ILS_ALL) |
Myself & | remove (Partial &, ILS_CUT_DIRECTIVE d=ILS_ALL, IlsBoolean weak=IlsFalse) |
Public Member Functions inherited from IlsIdentifiedListRelation | |
IlsRelationId | getIdentifier () const |
Public Member Functions inherited from IlsListRelation | |
unsigned int | getLength () const |
Returns the number of objects in the list. | |
IlsCardinality | getMaxCard () const |
IlsCardinality | getMinCard () const |
IlsBoolean | isLengthModified () |
During a notification phase, this member function returns IlsTrue if the number of objects in the list has been modified since the last notification phase. | |
IlsBoolean | isModified () |
During a notification phase, this member function returns IlsTrue if the list relation has been modified since the last notification phase, that is, if one or more items have been added to, or removed from, the list. | |
Static Public Member Functions | |
static Initial & | NewInitial () |
One-to-many ownership relation organized as list.
OwnerType | Class that contains the relation. The OwnerType must derive directly or transitively from IlsObject or IlsEntity . Derivation must be public. |
OwnedType | Class of the targets of the relation. The OwnedType must derive directly or transitively from IlsObject . Derivation must be public. |
Library: server
Ownership relations are relations in which one particular object is owned by, or belongs to, at most one other object. One-to-many relations can be defined as list-relations or as set-relations. Unlike set-relations, target objects in list-relations are listed in sequential order.
IlsOwnsList< OwnerType, OwnedType >::IlsOwnsList | ( | OwnerType & | owner, |
IlsRelationId | identifier = IlsDefaultRelationId , |
||
IlsActivity | activity = IlsModel::GetDefaultActivity() , |
||
IlsCardinality | mincard = 0 , |
||
IlsCardinality | maxcard = ILS_UNLIMITED_MAXCARD , |
||
Initial & | targets = (*new Initial()) , |
||
IlsBoolean | check_card = IlsTrue |
||
) |
Constructor.
owner | A reference to the owner object. |
identifier | A relation identifier of type IlsRelationId . This argument defaults to IlsDefaultRelationId . It is generally used to invert relations. |
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. |
mincard | The minimal cardinality of the list. This argument is optional and defaults to zero. |
maxcard | The maximal cardinality, which can be an unsigned integer or indeterminate. This argument is optional and defaults to ILS_UNLIMITED_MAXCARD . |
targets | a list of objects. Its default value, NewInitial() , creates an empty list. |
check_card | specifies whether cardinalities should be checked at object construction. |
IlsMinCardViolated | If the number of objects in targets is less than the value of mincard . |
IlsMaxCardViolated | If the number of objects in targets is greater than the value of maxcard . |
Myself& IlsOwnsList< OwnerType, OwnedType >::clear | ( | ) |
\short Empties the list.
IlsMinCardViolated | If the minimal cardinality is different from zero. The number of items remaining in the list will be equal to the minimal cardinality specified. |
IlsUpdateForbidden | If the member function isUpdateAllowed() returns IlsFalse for the type in which the relation is declared. |
Myself& IlsOwnsList< OwnerType, OwnedType >::cons | ( | COwnedTypePR | ) |
\short Adds an object to the list.
IlsMaxCardViolated | If the maximal cardinality has been reached. |
IlsUpdateForbidden | If the member function isUpdateAllowed() returns IlsFalse for the type in which the relation is declared. |
IlsOwnershipCycle | If a cycle has been detected among ownership relations. |
IlsAlreadyInserted | If the supplied object is already owned. |
|
virtual |
\short Is called when a cut is applied to the target of the relation.
IlsActivity IlsOwnsList< OwnerType, OwnedType >::getActivity | ( | ) | const |
\short Returns \c ILS_ACTIVE if the relation has
been set as active. Otherwise, it returns ILS_INACTIVE
.
For details, see the constructor.
OwnedType** IlsOwnsList< OwnerType, OwnedType >::getAdded | ( | int & | ) |
During a notification phase, this member function returns an array of pointers to the items that have been added to the list since the last notification phase.
It returns an empty array if no object has been added to the list-relation. The argument 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 [].
COwnedTypePR IlsOwnsList< OwnerType, OwnedType >::getFirst | ( | ) |
\short Returns the first item of the list.
IlsForbiddenOnEmptyList | If the list is empty. |
|
virtual |
This virtual member function is used to retrieve an identified object from the relation.
The member function IlsViewed::getKeyIdentifier()
is used to retrieve the identifier of the relation element.
Reimplemented from IlsViewedRel.
COwnedTypePR IlsOwnsList< OwnerType, OwnedType >::getLast | ( | ) |
\short Returns the last item of the list.
IlsForbiddenOnEmptyList | If the list is empty. |
OwnerType& IlsOwnsList< OwnerType, OwnedType >::getOwner | ( | ) | const |
\short Returns a reference to the owner object.
This function is useful especially in the case of derived relations.
OwnedType** IlsOwnsList< OwnerType, OwnedType >::getRemoved | ( | int & | ) |
During a notification phase, this member function returns an array of pointers to the items that have been removed from the list since the last notification phase.
It returns an empty array if no object has been removed from the list-relation. The argument 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 [].
|
static |
\short Builds an empty list which is used
by the constructor as the default value of the argument targets
.
Myself& IlsOwnsList< OwnerType, OwnedType >::operator<< | ( | COwnedTypePR | newe | ) |
Adds an item to the list.
\short Adds an object to the list.
IlsMaxCardViolated | If the maximal cardinality has been reached. |
IlsUpdateForbidden | If the member function isUpdateAllowed() returns IlsFalse for the type in which the relation is declared. |
IlsOwnershipCycle | If a cycle has been detected among ownership relations. |
IlsAlreadyInserted | If the supplied object is already owned. |
Myself& IlsOwnsList< OwnerType, OwnedType >::operator>> | ( | COwnedTypePR | olde | ) |
Removes an item from the list.
\short Removes an object from the list according
to the cut
instruction specified.
IlsUpdateForbidden | If the function isUpdateAllowed() returns IlsFalse for the type in which the relation is declared. |
IlsMinCardViolated | If the minimal cardinality has been reached. |
IlsNotFound | If the item to be removed does not belong to the list. |
Myself& IlsOwnsList< OwnerType, OwnedType >::remove | ( | COwnedTypePR | olde, |
ILS_CUT_DIRECTIVE | d = ILS_ALL |
||
) |
\short Removes an object from the list according
to the cut
instruction specified.
IlsUpdateForbidden | If the function isUpdateAllowed() returns IlsFalse for the type in which the relation is declared. |
IlsMinCardViolated | If the minimal cardinality has been reached. |
IlsNotFound | If the item to be removed does not belong to the list. |
Myself& IlsOwnsList< OwnerType, OwnedType >::remove | ( | Partial & | , |
ILS_CUT_DIRECTIVE | d = ILS_ALL , |
||
IlsBoolean | weak = IlsFalse |
||
) |
\short Removes the argument \c Partial from the list.
\short Removes an object from the list according
to the cut
instruction specified.
IlsUpdateForbidden | If the function isUpdateAllowed() returns IlsFalse for the type in which the relation is declared. |
IlsMinCardViolated | If the minimal cardinality has been reached. |
IlsNotFound | If the item to be removed does not belong to the list. |