IlsSortedInvertedRelationList
 
IlsSortedInvertedRelationList
Category 
Modeling class template
Inheritance Path 
IlsInvertedRelationList
IlsSortedInvertedRelationList
Related Pattern 
Bridge
Description 
Relations of type IlsSortedInvertedRelationList are similar to relations of type IlsInvertedRelationList. The only difference is that sorted list-relations are associated with a sort criterion that is used to automatically determine where a new object will be placed in a list.
The TargetType and the OriginType must derive publicly and directly or transitively from IlsEntity or IlsObject. Derivation must be public.
The Comparator class contains only one static function with the following signature:
static IlsBoolean Compare(OriginType&, OriginType&);
New objects will be added to a list at the position specified by the function compare.
If the function Comparator::compare(O1, O2); returns IlsTrue, O1 is considered greater than O2 and thus placed after O2 in the list. If this function returns IlsFalse, then O1 is considered less than O2 and thus inserted before O2 in the list. A list is sorted in the ascending order defined by the compare function. To invert the sort order defined by a given compare function, you have to change the return value into the opposite value.
Library 
<server>
Header File 
#include <ilserver/model.h>
Synopsis 
template <class TargetType, class OriginType, class Comparator>
class IlsSortedInvertedRelationList:
public IlsInvertedRelationList<TargetType,OriginType>
{
public:
IlsSortedInvertedRelationList
(TargetType& target,
IlsActivity activity=IlsModel::GetDefaultActivity(),
IlsCardinality mincard=0,
IlsCardinality maxcard=ILS_UNLIMITED_MAXCARD,
Initial& targets=newInitial(),
IlsBoolean check_card=IlsTrue);
Myself& cons(OriginType*);
Myself& operator<<(OriginType* newe);
};
Constructor 
IlsSortedInvertedRelationList
(TargetType& target,
IlsActivity activity=IlsModel::GetDefaultActivity(),
IlsCardinality mincard=0,
IlsCardinality maxcard=ILS_UNLIMITED_MAXCARD,
Initial& targets=newInitial(),
IlsBoolean check_card=IlsTrue);
This constructor takes the following arguments:
*A reference to the target object;
*A relation identifier of type IlsRelationId. This argument defaults to
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 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. This argument is optional and defaults to ILS_UNLIMITED_MAXCARD.
*The argument targets is a list of objects. It creates an empty list when set to its default value.
*The last argument check_card specifies whether cardinalities should be checked at construction.
Member Functions 
Myself& cons(OriginType*);
This function adds an object to the list at the position specified by the function compare. It throws the following exceptions:
*IlsMaxCardViolated if the maximal cardinality has been reached.
*IlsUpdateForbidden if the function isUpdateAllowed returns IlsFalse for the type in which the relation is declared.
Operators 
Myself& operator<<(OriginType* newe);
This operator adds an element to the list at the position specified by the
function compare. It throws the same exceptions as the member function IlsSortedInvertedRelationList::cons.
See Also 
IlsDerived, IlsEntity, IlsObject, IlsSortedOwnsList, IlsSortedUsesList

Version 5.8
Copyright © 2014, Rogue Wave Software, Inc. All Rights Reserved.