Server
API Reference Guide
Product Documentation:

Visualization Server
Documentation Home
List of all members | Public Types | Public Member Functions | Static Public Member Functions
IlsOwnsList< OwnerType, OwnedType > Class Template Reference

One-to-many ownership relation organized as list. More...

#include <ilserver/model.h>

Inheritance diagram for IlsOwnsList< OwnerType, OwnedType >:
IlsIdentifiedListRelation IlsListRelation IlsSortedOwnsList< OwnerType, OwnedType, Comparator >

Public Types

typedef IlsListRelationConstIterator< MyselfConstIterator
 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< MyselfIterator
 Non const iterator for the list.
 
typedef IlsOwnsList< OwnerType, OwnedType > Myself
 Myself is the type of the instantiated template class.
 
typedef IlsPartial< OwnerType, OwnedType, MyselfPartial
 This class is an intermediate class that stores list items.
 
typedef IlsListRelationPosition< MyselfPosition
 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.
 
Myselfclear ()
 
Myselfcons (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 IlsViewedgetIdentifiedElement (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.
 
Myselfoperator<< (COwnedTypePR newe)
 Adds an item to the list. More...
 
Myselfoperator>> (COwnedTypePR olde)
 Removes an item from the list. More...
 
COwnedTypePR operator[] (int i) const
 Returns the i-th list item.
 
Myselfremove (COwnedTypePR olde, ILS_CUT_DIRECTIVE d=ILS_ALL)
 
Myselfremove (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 InitialNewInitial ()
 

Detailed Description

template<class OwnerType, class OwnedType>
class IlsOwnsList< OwnerType, OwnedType >

One-to-many ownership relation organized as list.

Template Parameters
OwnerTypeClass that contains the relation. The OwnerType must derive directly or transitively from IlsObject or IlsEntity. Derivation must be public.
OwnedTypeClass 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.

See also
IlsException, IlsDefaultRelationId, IlsDerived, IlsEntity, IlsMoveDirective, IlsObject, IlsOwns, IlsOwnsDynamicArray, IlsOwnsFixedArray, IlsOwnsSet, IlsRelationId.

Constructor & Destructor Documentation

◆ IlsOwnsList()

template<class OwnerType , class OwnedType >
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.

Parameters
ownerA reference to the owner object.
identifierA relation identifier of type IlsRelationId. This argument defaults to IlsDefaultRelationId. It is generally used to invert relations.
activityspecifies 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.
mincardThe minimal cardinality of the list. This argument is optional and defaults to zero.
maxcardThe maximal cardinality, which can be an unsigned integer or indeterminate. This argument is optional and defaults to ILS_UNLIMITED_MAXCARD.
targetsa list of objects. Its default value, NewInitial(), creates an empty list.
check_cardspecifies whether cardinalities should be checked at object construction.
Exceptions
IlsMinCardViolatedIf the number of objects in targets is less than the value of mincard.
IlsMaxCardViolatedIf the number of objects in targets is greater than the value of maxcard.

Member Function Documentation

◆ clear()

template<class OwnerType , class OwnedType >
Myself& IlsOwnsList< OwnerType, OwnedType >::clear ( )
\short Empties the list.
Exceptions
IlsMinCardViolatedIf the minimal cardinality is different from zero. The number of items remaining in the list will be equal to the minimal cardinality specified.
IlsUpdateForbiddenIf the member function isUpdateAllowed() returns IlsFalse for the type in which the relation is declared.

◆ cons()

template<class OwnerType , class OwnedType >
Myself& IlsOwnsList< OwnerType, OwnedType >::cons ( COwnedTypePR  )
\short Adds an object to the list.
Exceptions
IlsMaxCardViolatedIf the maximal cardinality has been reached.
IlsUpdateForbiddenIf the member function isUpdateAllowed() returns IlsFalse for the type in which the relation is declared.
IlsOwnershipCycleIf a cycle has been detected among ownership relations.
IlsAlreadyInsertedIf the supplied object is already owned.

◆ cut()

template<class OwnerType , class OwnedType >
virtual void IlsOwnsList< OwnerType, OwnedType >::cut ( Partial ,
ILS_CUT_DIRECTIVE  d = ILS_ALL 
)
virtual
\short Is called when a cut is applied to the target of the relation.

◆ getActivity()

template<class OwnerType , class OwnedType >
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.

◆ getAdded()

template<class OwnerType , class OwnedType >
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 [].

◆ getFirst()

template<class OwnerType , class OwnedType >
COwnedTypePR IlsOwnsList< OwnerType, OwnedType >::getFirst ( )
\short Returns the first item of the list.
Exceptions
IlsForbiddenOnEmptyListIf the list is empty.

◆ getIdentifiedElement()

template<class OwnerType , class OwnedType >
virtual IlsViewed* IlsOwnsList< OwnerType, OwnedType >::getIdentifiedElement ( const IlsString id) const
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.

Note
On all subclasses of this class, the complexity of this method is always linear, in terms of the number of elements in the relation, even for set relations.

Reimplemented from IlsViewedRel.

◆ getLast()

template<class OwnerType , class OwnedType >
COwnedTypePR IlsOwnsList< OwnerType, OwnedType >::getLast ( )
\short Returns the last item of the list.
Exceptions
IlsForbiddenOnEmptyListIf the list is empty.

◆ getOwner()

template<class OwnerType , class OwnedType >
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.

◆ getRemoved()

template<class OwnerType , class OwnedType >
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 [].

◆ NewInitial()

template<class OwnerType , class OwnedType >
static Initial& IlsOwnsList< OwnerType, OwnedType >::NewInitial ( )
static
\short Builds an empty list which is used

by the constructor as the default value of the argument targets.

◆ operator<<()

template<class OwnerType , class OwnedType >
Myself& IlsOwnsList< OwnerType, OwnedType >::operator<< ( COwnedTypePR  newe)

Adds an item to the list.

\short Adds an object to the list.
Exceptions
IlsMaxCardViolatedIf the maximal cardinality has been reached.
IlsUpdateForbiddenIf the member function isUpdateAllowed() returns IlsFalse for the type in which the relation is declared.
IlsOwnershipCycleIf a cycle has been detected among ownership relations.
IlsAlreadyInsertedIf the supplied object is already owned.

◆ operator>>()

template<class OwnerType , class OwnedType >
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.

Exceptions
IlsUpdateForbiddenIf the function isUpdateAllowed() returns IlsFalse for the type in which the relation is declared.
IlsMinCardViolatedIf the minimal cardinality has been reached.
IlsNotFoundIf the item to be removed does not belong to the list.

◆ remove() [1/2]

template<class OwnerType , class OwnedType >
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.

Exceptions
IlsUpdateForbiddenIf the function isUpdateAllowed() returns IlsFalse for the type in which the relation is declared.
IlsMinCardViolatedIf the minimal cardinality has been reached.
IlsNotFoundIf the item to be removed does not belong to the list.

◆ remove() [2/2]

template<class OwnerType , class OwnedType >
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.

Exceptions
IlsUpdateForbiddenIf the function isUpdateAllowed() returns IlsFalse for the type in which the relation is declared.
IlsMinCardViolatedIf the minimal cardinality has been reached.
IlsNotFoundIf the item to be removed does not belong to the list.