IlsSortedUsesList
 
IlsSortedUsesList
Category 
Class template
Inheritance Path 
IlsUsesList
IlsSortedUsesList
Description 
Relations of type IlsSortedUsesList are similar to relations of type IlsUsesList. The only difference is that sorted list-relations can be associated with a sort criterion that is used to automatically determine where a new object will be placed in a list.
The UserType and the UsedType must directly or transitively derive from IlsEntity or IlsObject. Derivation must be public.
The Comparator class contains only one static function with the following signature:
[static] IlsBoolean Compare(const UsedType&,const UsedType&);
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 lower 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 UserType, class UsedType, class Comparator>
class IlsSortedUsesList:
public IlsUsesList<UserType,UsedType>
{
public:
IlsSortedUsesList
(UserType& user,
IlsRelationId identifier=IlsDefaultRelationId,
IlsActivity activity=IlsModel::GetDefaultActivity(),
IlsCardinality mincard=0,
IlsCardinality maxcard=ILS_UNLIMITED_MAXCARD,
Initial& used=newInitial(),
IlsBoolean check_card=IlsTrue);
Myself& cons(CUsedTypePR);
Myself& operator<<(CUsedTypePR newe);
};
Constructor 
IlsSortedUsesList
(UserType& user,
IlsRelationId identifier=IlsDefaultRelationId,
IlsActivity activity=IlsModel::GetDefaultActivity(),
IlsCardinality mincard=0,
IlsCardinality maxcard=ILS_UNLIMITED_MAXCARD,
Initial& used=newInitial(),
IlsBoolean check_card=IlsTrue);
This constructor takes the following arguments:
*A reference to the user 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 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. This argument is optional and defaults to ILS_UNLIMITED_MAXCARD.
*The argument used is a list of objects. Its creates an empty list when set to its default value.
*The argument check_card specifies whether cardinalities should be checked at construction.
Member Functions 
Myself& cons(CUsedTypePR);
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.
*IlsUnOwnedUse if the specified object is neither an owned object nor an entity, and if the member function IlsModel::IsIntegrityChecked returns IlsTrue.
*IlsUpdateForbidden if the function isUpdateAllowed returns IlsFalse for the type in which the relation is declared.
Operators 
Myself& operator<<(CUsedTypePR newe);
This operator adds an element to the list at the position specified by the function compare. It throws the same exceptions as the function IlsSortedUsesList::cons.
See Also 
IlsDerived, IlsEntity, IlsObject, IlsSortedOwnsList

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