Inverted relation list. More...
#include <ilserver/model.h>
Classes | |
class | ConstIterator |
Const iterator. More... | |
class | Iterator |
Non const iterator. More... | |
class | Position |
This class is nested in the class template IlsInvertedRelationList . It sets an iterator to a given position. More... | |
Public Types | |
typedef Relations | Initial |
This class provides a list of origin objects when a relation is created. More... | |
typedef IlsInvertedRelationList< TargetType, OriginType > | Myself |
Myself is the type of the instantiated template class. | |
Public Member Functions | |
IlsInvertedRelationList (TargetType &target, IlsActivity activity=IlsModel::GetDefaultActivity(), IlsCardinality mincard=0, IlsCardinality maxcard=ILS_UNLIMITED_MAXCARD, Initial &targets=(*new Initial()), IlsBoolean check_card=IlsTrue) | |
virtual IlsViewed * | getIdentifiedElement (const IlsString &id) const |
This virtual member function is used to retrieve an identified object from the relation. More... | |
virtual IlsBoolean | hasElement (IlsViewed &) const |
This virtual member function returns IlsTrue if the element is a target of the relation or IlsFalse otherwise. | |
Accessors | |
TargetType & | getTarget () const |
Returns the target of the relation. | |
OriginType * | operator[] (int i) const |
Returns the i -th list element. | |
OriginType * | getFirst () const |
Returns the first item of the list. More... | |
OriginType * | getLast () const |
Returns the last item of the list. More... | |
IlsBoolean | isIn (OriginType *e) |
Returns IlsTrue if the specified item belongs to the list. | |
Adding/Removing Objects | |
Myself & | cons (OriginType *newe) |
Adds the specified object to the list. More... | |
Myself & | operator<< (OriginType *newe) |
This insertion operator adds an object to the list. More... | |
Myself & | remove (OriginType *olde) |
Removes the specified object from the list. More... | |
Myself & | operator>> (OriginType *olde) |
This extraction operator removes an object from the list. More... | |
Myself & | clear () |
Empties the list. More... | |
Notification | |
OriginType ** | getAdded (int &) |
During a notification phase, this member function returns an array of pointers to the objects that have been added to the list since the last notification phase. More... | |
OriginType ** | getRemoved (int &) |
During a notification phase, this member function returns an array of pointers to the objects that have been removed from the list since the last notification phase. More... | |
![]() | |
unsigned int | getLength () const |
Returns the number of objects in the list. | |
IlsCardinality | getMaxCard () const |
Indicates the maximal cardinality of the list. | |
IlsCardinality | getMinCard () const |
Indicates the minimal cardinality of the list. | |
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 () |
Builds an empty list which is used by the constructor as the default value of the argument origins . | |
Inverted relation list.
TargetType | Target class of the direct relation. |
OriginType | Class that contains the direct relation. |
Library: server
Rogue Wave Server lets you invert several relations by maintaining a list of back pointers to the origins of a set of relations. This list of pointers is declared as an instance of the class template IlsInvertedRelationList
and maintained by means of the functions setContext()
and unsetContext()
. Modifying an inverted relation may trigger the recomputation of derived data members that depend on that relation.
The IlsInvertedRelationList
template makes a forward declaration of the function IlsViewed* Ils2Viewed(OriginType*)
and uses it in its implementation. This is to prevent the compiler from requiring visibility on the class OriginType
when instantiating the inverted relation template. The implementation of the Ils2Viewed()
function is expanded by the macro ILS_OBJECT_DECL()
or its derivatives. If you do not want to use that macro because the type OriginType
is not notified by views, you can define your own function in a source of your application that has visibility on the class OriginType
, as follows:
Bridge
typedef Relations IlsInvertedRelationList< TargetType, OriginType >::Initial |
This class provides a list of origin objects when a relation is created.
This list must contain at least as many items as specified for the minimal cardinality.
IlsInvertedRelationList< TargetType, OriginType >::IlsInvertedRelationList | ( | TargetType & | target, |
IlsActivity | activity = IlsModel::GetDefaultActivity() , |
||
IlsCardinality | mincard = 0 , |
||
IlsCardinality | maxcard = ILS_UNLIMITED_MAXCARD , |
||
Initial & | targets = (*new Initial()) , |
||
IlsBoolean | check_card = IlsTrue |
||
) |
This constructor takes the following arguments:
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 static member function IlsModel::GetDefaultActivity()
, which is ILS_INACTIVE
by default.ILS_UNLIMITED_MAXCARD
.NewInitial()
, creates an empty list.check_card
specifies whether cardinalities should be checked at object construction.IlsMinCardViolated | If the length of targets is less than the value assigned to mincard . |
IlsMaxCardViolated | If the length of targets is greater than the value of maxcard . |
Myself& IlsInvertedRelationList< TargetType, OriginType >::clear | ( | ) |
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. |
Myself& IlsInvertedRelationList< TargetType, OriginType >::cons | ( | OriginType * | newe | ) |
Adds the specified object to the list.
IlsMaxCardViolated | If this function is called when the maximum cardinality has been reached. |
OriginType** IlsInvertedRelationList< TargetType, OriginType >::getAdded | ( | int & | ) |
During a notification phase, this member function returns an array of pointers to the objects 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.
OriginType* IlsInvertedRelationList< TargetType, OriginType >::getFirst | ( | ) | const |
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.
OriginType* IlsInvertedRelationList< TargetType, OriginType >::getLast | ( | ) | const |
Returns the last item of the list.
IlsForbiddenOnEmptyList | If the list is empty. |
OriginType** IlsInvertedRelationList< TargetType, OriginType >::getRemoved | ( | int & | ) |
During a notification phase, this member function returns an array of pointers to the objects 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.
Myself& IlsInvertedRelationList< TargetType, OriginType >::operator<< | ( | OriginType * | newe | ) |
This insertion operator adds an object to the list.
IlsMaxCardViolated | If this function is called when the maximum cardinality has been reached. |
Myself& IlsInvertedRelationList< TargetType, OriginType >::operator>> | ( | OriginType * | olde | ) |
This extraction operator removes an object from the list.
IlsMinCardViolated | If this function is called when the minimal cardinality has been reached |
IlsNotFound | If removing an object that does not belong to the list. |
Myself& IlsInvertedRelationList< TargetType, OriginType >::remove | ( | OriginType * | olde | ) |
Removes the specified object from the list.
IlsMinCardViolated | If this function is called when the minimal cardinality has been reached |
IlsNotFound | If removing an object that does not belong to the list. |
© Copyright 2018, Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave is a registered trademark of Rogue Wave Software, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.