Server
API Reference Guide
Product Documentation:

Visualization Server
Documentation Home
List of all members | Classes | Public Types | Public Member Functions | Static Public Member Functions
IlsInvertedRelationList< TargetType, OriginType > Class Template Reference

Inverted relation list. More...

#include <ilserver/model.h>

Inheritance diagram for IlsInvertedRelationList< TargetType, OriginType >:
IlsListRelation IlsSortedInvertedRelationList< TargetType, OriginType, Comparator >

Classes

class  ConstIterator
 Const iterator. More...
 
class  Iterator
 Non const iterator. More...
 
class  Position
 

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 IlsViewedgetIdentifiedElement (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.
 
Adding/Removing Objects
Myselfcons (OriginType *newe)
 
Myselfoperator<< (OriginType *newe)
 This insertion operator adds an object to the list. More...
 
Myselfremove (OriginType *olde)
 
Myselfoperator>> (OriginType *olde)
 This extraction operator removes an object from the list. More...
 
Myselfclear ()
 
virtual void reset ()
 
OriginType ** getPointerArray (int &)
 
IlsBoolean notify (IlsView *, IlsRelSubscribing *, ILS_NOTIFY_STATE=ILS_NOTIFY_DEFAULT)
 
- 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 ()
 

Accessors

TargetType & getTarget () const
 Returns the target of the relation.
 
RelationsgetRelations () const
 Returns the target of the relation.
 
OriginType * operator[] (int i) const
 Returns the i-th list element.
 
OriginType * getFirst () const
 
OriginType * getLast () const
 
IlsBoolean isIn (OriginType *e)
 
void resetSentinel ()
 Returns the target of the relation.
 

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...
 
virtual IlsBoolean fillViewedTable (IlsPtrArray< IlsViewed > &)
 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...
 
IlsViewedIls2Viewed (OriginType *)
 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...
 

Detailed Description

template<class TargetType, class OriginType>
class IlsInvertedRelationList< TargetType, OriginType >

Inverted relation list.

Template Parameters
TargetTypeTarget class of the direct relation.
OriginTypeClass 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:

Ils2Viewed* Ils2Viewed(TargetType* obj){return obj;}
Related Pattern

Bridge

See also
IlsException, IlsDerived, IlsEntity, IlsInvertedRelationList::Initial, IlsInvertedRelationList::ConstIterator, IlsInvertedRelationList::Iterator, IlsInvertedRelationList::Position, IlsObject, IlsOwnsList, IlsUsesList, setContext(), unsetContext().

Member Typedef Documentation

◆ Initial

template<class TargetType , class OriginType >
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.

Constructor & Destructor Documentation

◆ IlsInvertedRelationList()

template<class TargetType , class OriginType >
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:

  • A reference to the target object (that is, to the object in which the relation is declared).
  • 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 static member function IlsModel::GetDefaultActivity(), which is ILS_INACTIVE by default.
  • The minimal cardinality of the list: This argument is optional and defaults to zero.
  • The maximal cardinality of the list. The maximal cardinality can be an unsigned integer, or can be indetermined. This argument is optional and defaults to ILS_UNLIMITED_MAXCARD.
  • The argument targets is a list of objects. Its default value, NewInitial(), creates an empty list.
  • The argument check_card specifies whether cardinalities should be checked at object construction.
Exceptions
IlsMinCardViolatedIf the length of targets is less than the value assigned to mincard.
IlsMaxCardViolatedIf the length of targets is greater than the value of maxcard.

Member Function Documentation

◆ clear()

template<class TargetType , class OriginType >
Myself& IlsInvertedRelationList< TargetType, OriginType >::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.

◆ cons()

template<class TargetType , class OriginType >
Myself& IlsInvertedRelationList< TargetType, OriginType >::cons ( OriginType *  newe)
\short Adds the specified object to the list.
Exceptions
IlsMaxCardViolatedIf this function is called when the maximum cardinality has been reached.

◆ fillViewedTable()

template<class TargetType , class OriginType >
virtual IlsBoolean IlsInvertedRelationList< TargetType, OriginType >::fillViewedTable ( IlsPtrArray< IlsViewed > &  )
protectedvirtual

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.

Implements IlsViewedRel.

◆ getAdded()

template<class TargetType , class OriginType >
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.

◆ getFirst()

template<class TargetType , class OriginType >
OriginType* IlsInvertedRelationList< TargetType, OriginType >::getFirst ( ) const
\short Returns the first item of the list.
Exceptions
IlsForbiddenOnEmptyListIf the list is empty.

◆ getIdentifiedElement()

template<class TargetType , class OriginType >
virtual IlsViewed* IlsInvertedRelationList< TargetType, OriginType >::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 TargetType , class OriginType >
OriginType* IlsInvertedRelationList< TargetType, OriginType >::getLast ( ) const
\short Returns the last item of the list.
Exceptions
IlsForbiddenOnEmptyListIf the list is empty.

◆ getPointerArray()

template<class TargetType , class OriginType >
OriginType** IlsInvertedRelationList< TargetType, OriginType >::getPointerArray ( int &  )
\short Adds the specified object to the list.
Exceptions
IlsMaxCardViolatedIf this function is called when the maximum cardinality has been reached.

◆ getRemoved()

template<class TargetType , class OriginType >
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.

◆ isIn()

template<class TargetType , class OriginType >
IlsBoolean IlsInvertedRelationList< TargetType, OriginType >::isIn ( OriginType *  e)
\short Returns \c IlsTrue if the specified item

belongs to the list.

◆ NewInitial()

template<class TargetType , class OriginType >
static Initial& IlsInvertedRelationList< TargetType, OriginType >::NewInitial ( )
static
\short Builds an empty list which is used

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

◆ notify()

template<class TargetType , class OriginType >
IlsBoolean IlsInvertedRelationList< TargetType, OriginType >::notify ( IlsView *  ,
IlsRelSubscribing *  ,
ILS_NOTIFY_STATE  = ILS_NOTIFY_DEFAULT 
)
virtual
\short Adds the specified object to the list.
Exceptions
IlsMaxCardViolatedIf this function is called when the maximum cardinality has been reached.

Implements IlsViewedRel.

◆ operator<<()

template<class TargetType , class OriginType >
Myself& IlsInvertedRelationList< TargetType, OriginType >::operator<< ( OriginType *  newe)

This insertion operator adds an object to the list.

\short Adds the specified object to the list.
Exceptions
IlsMaxCardViolatedIf this function is called when the maximum cardinality has been reached.

◆ operator>>()

template<class TargetType , class OriginType >
Myself& IlsInvertedRelationList< TargetType, OriginType >::operator>> ( OriginType *  olde)

This extraction operator removes an object from the list.

\short Removes the specified object from the list.
Exceptions
IlsMinCardViolatedIf this function is called when the minimal cardinality has been reached
IlsNotFoundIf removing an object that does not belong to the list.

◆ remove()

template<class TargetType , class OriginType >
Myself& IlsInvertedRelationList< TargetType, OriginType >::remove ( OriginType *  olde)
\short Removes the specified object from the list.
Exceptions
IlsMinCardViolatedIf this function is called when the minimal cardinality has been reached
IlsNotFoundIf removing an object that does not belong to the list.

◆ reset()

template<class TargetType , class OriginType >
virtual void IlsInvertedRelationList< TargetType, OriginType >::reset ( )
virtual
\short Adds the specified object to the list.
Exceptions
IlsMaxCardViolatedIf this function is called when the maximum cardinality has been reached.

Reimplemented from IlsViewedRel.

Friends And Related Function Documentation

◆ Ils2Viewed

template<class TargetType , class OriginType >
IlsViewed* Ils2Viewed ( OriginType *  )
friend

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.

IlsInvertedRelationList::Ils2Viewed
friend IlsViewed * Ils2Viewed(OriginType *)
During a notification phase, this member function returns an array of pointers to the objects that ha...