Server
API Reference Guide
Product Documentation:

Rogue Wave Server
Documentation Home
List of all members | Public Types | Public Member Functions | Static Public Member Functions
IlsOwnsSet< OwnerType, OwnedType, KeyType, KeyManager > Class Template Reference

Non-ordered one-to-many ownership relation. More...

#include <ilserver/model.h>

Inheritance diagram for IlsOwnsSet< OwnerType, OwnedType, KeyType, KeyManager >:
IlsSetRelation IlsSetContext< KeyType >

Public Types

typedef IlsSetRelationIterator< MyselfIterator
 Set iterator.
 
typedef IlsOwnsSet< OwnerType, OwnedType, KeyType, KeyManager > Myself
 Myself is the type of the instantiated template class.
 

Public Member Functions

 IlsOwnsSet (OwnerType &owner, IlsRelationId identifier=IlsDefaultRelationId, IlsActivity activity=IlsModel::GetDefaultActivity(), IlsCardinality mincard=0, IlsCardinality maxcard=ILS_UNLIMITED_MAXCARD, Initial &targets=(*new Initial()), IlsBoolean check_card=IlsTrue)
 Constructor. More...
 
virtual ~IlsOwnsSet ()
 This destructor breaks all the relations in the set.
 
Myselfclear ()
 
virtual void cut (Partial &, ILS_CUT_DIRECTIVE d=ILS_ALL)
 
OwnedTypeP get (CKeyTypeR identifier)
 Returns the object associated with the specified key; otherwise, it returns 0.
 
OwnedType ** getAdded (int &)
 During a notification phase, this member function returns an array of pointers to the items that have been added to the set since the last notification phase. More...
 
unsigned int getCount ()
 Returns the number of objects in the set at a given time.
 
virtual IlsViewedgetIdentifiedElement (const IlsString &id) const
 This virtual member function is used to retrieve an identified object from the relation. More...
 
OwnerType & getOwner () const
 
OwnedType ** getRemoved (int &)
 During a notification phase, this member function returns an array of pointers to the items that have been removed from the set since the last notification phase. More...
 
virtual IlsBoolean hasElement (IlsViewed &) const
 This virtual member function returns IlsTrue if the element is a target of the relation or IlsFalse otherwise.
 
IlsBoolean isIn (CKeyTypeR identifier)
 
Myselfoperator<< (COwnedTypePR v)
 
Myselfoperator>> (COwnedTypePR v)
 
OwnedTypeP operator[] (CKeyTypeR identifier)
 This operator is identical to the function get.
 
Myselfput (COwnedTypePR)
 
Myselfsuppress (CKeyTypeR identifier, ILS_CUT_DIRECTIVE=ILS_ALL)
 
- Public Member Functions inherited from IlsSetRelation
IlsActivity getActivity () const
 
unsigned int getCount () const
 Returns the number of objects in the set at a given time.
 
IlsRelationId getIdentifier () const
 Returns the relation identifier.
 
IlsCardinality getMaxCard () const
 Returns the maximal cardinality specified for the set.
 
IlsCardinality getMinCard () const
 Returns the minimal cardinality specified for the set.
 
IlsBoolean isCountModified ()
 
IlsBoolean isModified ()
 Indicates whether the set has been modified.
 

Static Public Member Functions

static InitialNewInitial ()
 

Detailed Description

template<class OwnerType, class OwnedType, class KeyType, class KeyManager>
class IlsOwnsSet< OwnerType, OwnedType, KeyType, KeyManager >

Non-ordered one-to-many ownership relation.

Template Parameters
OwnerTypeClass that contains the relation,
OwnedTypeClass of the targets of the relation.
KeyTypeThe type of the key used to store objects in a set and retrieve objects from a set.
KeyManagerA class that specifies how to handle keys.

Library: server

Rogue Wave Server lets you declare ownership relations among object classes. Ownership relations are relations in which one particular object is owned by at most one other object. The owner object, on the other hand, can own one or more other objects. One-to-many relations can be defined as list-relations or as set-relations. Unlike list-relations, target objects in set-relations are not listed in sequential order but are grouped together in a non-ordered set and are directly accessible by a key. Such relations are declared within the owner class as instances of the class template IlsOwnsSet.

OwnerType must derive directly or transitively from IlsObject or IlsEntity. OwnedType must derive from IlsObject. Derivation must be public.

KeyType is the type of the key used to store objects in a set and retrieve objects from a set. KeyManager is a class that specifies how to handle keys. This class must contain the three following static member functions:

static KeyType GetKey(OwnedType&);
static IlsBoolean Match(KeyType lhs, KeyType rhs);
static long Hash(KeyType key, int size);
See also
IlsEntity, IlsHashKeyManager, IlsObject, IlsOwnsList, IlsOwnsSet::Iterator, IlsUsesSet.

Constructor & Destructor Documentation

◆ IlsOwnsSet()

template<class OwnerType , class OwnedType , class KeyType , class KeyManager >
IlsOwnsSet< OwnerType, OwnedType, KeyType, KeyManager >::IlsOwnsSet ( OwnerType &  owner,
IlsRelationId  identifier = IlsDefaultRelationId,
IlsActivity  activity = IlsModel::GetDefaultActivity(),
IlsCardinality  mincard = 0,
IlsCardinality  maxcard = ILS_UNLIMITED_MAXCARD,
Initial targets = (*new Initial()),
IlsBoolean  check_card = IlsTrue 
)

Constructor.

Parameters
ownerA reference to the owner object.
identifierA relation identifier of type IlsRelationId. This argument defaults to IlsDefaultRelationId. It is generally used to invert relations.
activitySpecifies 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.
mincardThe minimal cardinality of the list. This argument is optional and defaults to zero.
maxcardThe maximal cardinality of the list. This argument is optional and defaults to ILS_UNLIMITED_MAXCARD.
targetsA list of objects. Its creates an empty list when set to its default value.
check_cardSpecifies whether cardinalities should be checked at construction.

Member Function Documentation

◆ clear()

template<class OwnerType , class OwnedType , class KeyType , class KeyManager >
Myself& IlsOwnsSet< OwnerType, OwnedType, KeyType, KeyManager >::clear ( )
\short Empties the list.
Exceptions
IlsMinCardViolatedIf the minimal cardinality is different from zero. The number of objects left in the set will be equal to the minimal cardinality specified.
IlsUpdateForbiddenIf the function isUpdatedAllowed() returns IlsFalse for the type in which the relation is declared.

◆ cut()

template<class OwnerType , class OwnedType , class KeyType , class KeyManager >
virtual void IlsOwnsSet< OwnerType, OwnedType, KeyType, KeyManager >::cut ( Partial ,
ILS_CUT_DIRECTIVE  d = ILS_ALL 
)
virtual
\short Is called when a cut is applied to one of the owned objects.

◆ getAdded()

template<class OwnerType , class OwnedType , class KeyType , class KeyManager >
OwnedType** IlsOwnsSet< OwnerType, OwnedType, KeyType, KeyManager >::getAdded ( int &  )

During a notification phase, this member function returns an array of pointers to the items that have been added to the set since the last notification phase.

It returns an empty array if no object has been added to the list relation. The argument accepts the size of the array as a return value.

You must explicitly destroy this array when you no longer need it. To do so, use delete with square brackets [].

◆ getIdentifiedElement()

template<class OwnerType , class OwnedType , class KeyType , class KeyManager >
virtual IlsViewed* IlsOwnsSet< OwnerType, OwnedType, KeyType, KeyManager >::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.

◆ getOwner()

template<class OwnerType , class OwnedType , class KeyType , class KeyManager >
OwnerType& IlsOwnsSet< OwnerType, OwnedType, KeyType, KeyManager >::getOwner ( ) const
\short Returns a reference to the owner object.

It is especially useful in the case of derived relations.

◆ getRemoved()

template<class OwnerType , class OwnedType , class KeyType , class KeyManager >
OwnedType** IlsOwnsSet< OwnerType, OwnedType, KeyType, KeyManager >::getRemoved ( int &  )

During a notification phase, this member function returns an array of pointers to the items that have been removed from the set since the last notification phase.

It returns an empty array if no object has been removed from the set-relation. The argument accepts the size of the array as a return value.

You must explicitly destroy this array when you no longer need it. To do so, use delete with square brackets [].

◆ isIn()

template<class OwnerType , class OwnedType , class KeyType , class KeyManager >
IlsBoolean IlsOwnsSet< OwnerType, OwnedType, KeyType, KeyManager >::isIn ( CKeyTypeR  identifier)
\short Indicates whether the set holds an object

associated with the key specified.

◆ NewInitial()

template<class OwnerType , class OwnedType , class KeyType , class KeyManager >
static Initial& IlsOwnsSet< OwnerType, OwnedType, KeyType, KeyManager >::NewInitial ( )
static
\short Builds an empty set which is used by the

constructor as the default value of the argument targets.

◆ operator<<()

template<class OwnerType , class OwnedType , class KeyType , class KeyManager >
Myself& IlsOwnsSet< OwnerType, OwnedType, KeyType, KeyManager >::operator<< ( COwnedTypePR  v)
\short Adds an object to the set.
\short Puts an object in the set.

A set cannot contain two objects associated with the same key.

Exceptions
IlsMaxCardViolatedIf the maximal cardinality has been reached.
IlsUpdateForbiddenIf the function isUpdateAllowed() returns IlsFalse for the type in which the relation is declared.
IlsOwnershipCycleIf a cycle has been detected among ownership relations.
IlsAlreadyInsertedIf the supplied object is already owned.
IlsAlreadyInSetIf the supplied object is already in the set.

◆ operator>>()

template<class OwnerType , class OwnedType , class KeyType , class KeyManager >
Myself& IlsOwnsSet< OwnerType, OwnedType, KeyType, KeyManager >::operator>> ( COwnedTypePR  v)
\short Removes an object from the set.
\short Removes the object associated with the
specified key according to the specified \c cut instruction.
Exceptions
IlsUpdateForbiddenIf the function isUpdatedAllowed() returns IlsFalse for the type in which the relation is declared.
IlsMinCardViolatedIf the minimal cardinality has been reached.
IlsNotFoundIf no object is associated with the specified key.

◆ put()

template<class OwnerType , class OwnedType , class KeyType , class KeyManager >
Myself& IlsOwnsSet< OwnerType, OwnedType, KeyType, KeyManager >::put ( COwnedTypePR  )
\short Puts an object in the set.

A set cannot contain two objects associated with the same key.

Exceptions
IlsMaxCardViolatedIf the maximal cardinality has been reached.
IlsUpdateForbiddenIf the function isUpdateAllowed() returns IlsFalse for the type in which the relation is declared.
IlsOwnershipCycleIf a cycle has been detected among ownership relations.
IlsAlreadyInsertedIf the supplied object is already owned.
IlsAlreadyInSetIf the supplied object is already in the set.

◆ suppress()

template<class OwnerType , class OwnedType , class KeyType , class KeyManager >
Myself& IlsOwnsSet< OwnerType, OwnedType, KeyType, KeyManager >::suppress ( CKeyTypeR  identifier,
ILS_CUT_DIRECTIVE  = ILS_ALL 
)
\short Removes the object associated with the
specified key according to the specified \c cut instruction.
Exceptions
IlsUpdateForbiddenIf the function isUpdatedAllowed() returns IlsFalse for the type in which the relation is declared.
IlsMinCardViolatedIf the minimal cardinality has been reached.
IlsNotFoundIf no object is associated with the specified key.
IlsBoolean
bool IlsBoolean
The type IlsBoolean handles Boolean values. A Boolean value is true when set to IlsTrue and false whe...
Definition: config.h:194