IlsSortedOwnsList
 
IlsSortedOwnsList
Category 
Class template
Inheritance Path 
IlsOwnsList
IlsSortedOwnsList
Description 
Relations of type IlsSortedOwnsList are similar to relations of type IlsOwnsList. 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 OwnerType must directly or transitively derive from IlsEntity or IlsObject. The OwnedType must directly or transitively derive from IlsObject. Derivation must be public.
The Comparator class contains only one static function with the following signature:
[static] IlsBoolean Compare(const OwnedType&,const OwnedType&);
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 OwnerType, class OwnedType, class Comparator>
class IlsSortedOwnsList:
public IlsOwnsList<OwnerType,OwnedType>
{
public:
IlsSortedOwnsList
(OwnerType& owner,
IlsRelationId identifier=IlsDefaultRelationId,
IlsActivity activity=IlsModel::GetDefaultActivity(),
IlsCardinality mincard=0,
IlsCardinality maxcard=ILS_UNLIMITED_MAXCARD,
Initial& owned=newInitial(),
IlsBoolean check_card=IlsTrue);
Myself& cons(COwnedTypePR);
Myself& operator<<(COwnedTypePR newe);
};
Constructor 
IlsSortedOwnsList
(OwnerType& owner,
IlsRelationId identifier=IlsDefaultRelationId,
IlsActivity activity=IlsModel::GetDefaultActivity(),
IlsCardinality mincard=0,
IlsCardinality maxcard=ILS_UNLIMITED_MAXCARD,
Initial& owned=newInitial(),
IlsBoolean check_card=IlsTrue);
This constructor takes the following arguments:
*A reference to the owner 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 owned 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(COwnedTypePR);
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.
*IlsOwnershipCycle if a cycle has been detected among ownership relations.
*IlsAlreadyInserted if the supplied object is already owned.
Operators 
Myself& operator<<(COwnedTypePR 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 IlsSortedOwnsList::cons.
See Also 
IlsEntity, IlsObject, IlsSortedUsesList

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