Server
API Reference Guide
Product Documentation:

Rogue Wave Server
Documentation Home
List of all members | Public Types | Public Member Functions
IlsInvertedRelation< TargetType, OriginType > Class Template Reference

Rogue Wave Server lets you invert a relation by maintaining a back pointer to the origin of that relation. More...

#include <ilserver/model.h>

Inheritance diagram for IlsInvertedRelation< TargetType, OriginType >:
IlsViewedRel

Public Types

typedef IlsInvertedRelation< TargetType, OriginType > Myself
 Myself is the type of the instantiated template class.
 

Public Member Functions

 IlsInvertedRelation (TargetType &o, IlsActivity activity=IlsModel::GetDefaultActivity())
 
Accessors
OriginType * getValue ()
 
OriginType * getPointer ()
 
TargetType & getTarget () const
 Returns the target of the relation.
 
Operators
 operator OriginType * ()
 
OriginType * getValueQuietly () const
 
OriginType * operator-> ()
 This dereference operator returns the origin of the relation.
 
OriginType & operator* ()
 This indirection operator returns a reference to the origin of the relation.
 
IlsBoolean operator! ()
 
IlsBoolean operator== (OriginType *rhs)
 Checks whether the origin-type is equal to another origin-type.
 
IlsBoolean operator!= (OriginType *rhs)
 
IlsBoolean operator== (Myself &rhs)
 
IlsBoolean operator!= (Myself &rhs)
 
Myselfoperator= (OriginType *rhs)
 Assigns a new origin to the inverted relation.
 
Myselfoperator= (Myself &rhs)
 Assigns an inverted relation to the inverted relation.
 
IlsViewedgetViewedHolder ()
 
virtual IlsBoolean isUnary () const
 
Modifiers
Myselfset (OriginType *rhs, IlsBoolean avoid_notify=IlsFalse)
 Assigns a new origin to the inverted relation.
 
Myselfclear ()
 Sets the relation to zero.
 
- Public Member Functions inherited from IlsViewedRel
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.
 
IlsBoolean isViewed ()
 This member function returns IlsTrue if at least one regular view (as opposed to a multithreaded view) subscribes to the relation. More...
 
virtual void onSubscribe (IlsView &)
 This empty virtual member function is called each time a view subscribes to the relation.
 
virtual void onUnsubscribe (IlsView &)
 This empty virtual member function is called each time the subscription of a view to the relation is canceled.
 

Notification

IlsBoolean isModified ()
 During a notification phase, this member function returns IlsTrue only if the relation has been modified since the last notification phase.
 
OriginType * getOldValue ()
 
IlsBoolean notify (IlsView *, IlsRelSubscribing *, ILS_NOTIFY_STATE=ILS_NOTIFY_DEFAULT)
 During a notification phase, this member function returns IlsTrue only if the relation has been modified since the last notification phase.
 
virtual unsigned int getElementCount ()
 During a notification phase, this member function returns IlsTrue only if the relation has been modified since the last notification phase.
 
virtual IlsBoolean fillViewedTable (IlsPtrArray< IlsViewed > &)
 During a notification phase, this member function returns IlsTrue only if the relation has been modified since the last notification phase.
 
IlsViewedIls2Viewed (OriginType *)
 During a notification phase, this member function returns IlsTrue only if the relation has been modified since the last notification phase.
 

Additional Inherited Members

- Protected Member Functions inherited from IlsViewedRel
 IlsViewedRel ()
 This is the protected constructor of the class.
 

Detailed Description

template<class TargetType, class OriginType>
class IlsInvertedRelation< TargetType, OriginType >

Rogue Wave Server lets you invert a relation by maintaining a back pointer to the origin of that relation.

Template Parameters
TargetTypeTarget class of the direct relation.
OriginTypeClass that contains the direct relation.

Library: server

This pointer is declared as an instance of the class template IlsInvertedRelation and maintained by means of the functions setContext() and unsetContext(). A relation of type IlsInvertedRelation contains an entry. Modifying it may therefore trigger the recomputation of derived members or notification.

The IlsInvertedRelation template makes a forward declaration of the function IlsViewed* Ils2Viewed(OriginType*) and uses it in its implementation. This to avoid the compiler to require 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
IlsEntity, IlsEntry, IlsObject, IlsOwns, IlsUses, setContext(), unsetContext().

Constructor & Destructor Documentation

◆ IlsInvertedRelation()

template<class TargetType , class OriginType >
IlsInvertedRelation< TargetType, OriginType >::IlsInvertedRelation ( TargetType &  o,
IlsActivity  activity = IlsModel::GetDefaultActivity() 
)

As its first argument, this constructor takes a reference to the type in which the relation is declared. It initializes the back pointer to zero.

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.

Member Function Documentation

◆ getOldValue()

template<class TargetType , class OriginType >
OriginType* IlsInvertedRelation< TargetType, OriginType >::getOldValue ( )
\short During a notification phase, this member function returns a
smart pointer to the object that was the target of the relation before

the notification phase.

◆ getPointer()

template<class TargetType , class OriginType >
OriginType* IlsInvertedRelation< TargetType, OriginType >::getPointer ( )
\short Returns a pointer to the origin of the relation.

It is useful especially when the conversion operator cannot be used or when the compiler is likely to encounter multiple user-defined conversions.

◆ getValue()

template<class TargetType , class OriginType >
OriginType* IlsInvertedRelation< TargetType, OriginType >::getValue ( )
\short Returns a pointer to the origin of the relation.

It is useful especially when the conversion operator cannot be used or when the compiler is likely to encounter multiple user-defined conversions.

◆ getValueQuietly()

template<class TargetType , class OriginType >
OriginType* IlsInvertedRelation< TargetType, OriginType >::getValueQuietly ( ) const
\short Lets you use inverted relations as if they were pointers.

This operator converts the relation to a pointer to an object of the OriginType. It is equivalent to the member function getValue() (see above).

◆ getViewedHolder()

template<class TargetType , class OriginType >
IlsViewed& IlsInvertedRelation< TargetType, OriginType >::getViewedHolder ( )
virtual
\short Lets you use inverted relations as if they were pointers.

This operator converts the relation to a pointer to an object of the OriginType. It is equivalent to the member function getValue() (see above).

Implements IlsViewedRel.

◆ isUnary()

template<class TargetType , class OriginType >
virtual IlsBoolean IlsInvertedRelation< TargetType, OriginType >::isUnary ( ) const
virtual
\short Lets you use inverted relations as if they were pointers.

This operator converts the relation to a pointer to an object of the OriginType. It is equivalent to the member function getValue() (see above).

Implements IlsViewedRel.

◆ operator OriginType *()

template<class TargetType , class OriginType >
IlsInvertedRelation< TargetType, OriginType >::operator OriginType * ( )
\short Lets you use inverted relations as if they were pointers.

This operator converts the relation to a pointer to an object of the OriginType. It is equivalent to the member function getValue() (see above).

◆ operator!()

template<class TargetType , class OriginType >
IlsBoolean IlsInvertedRelation< TargetType, OriginType >::operator! ( )
\short Returns \c IlsTrue if the inverted relation is

set to 0.

◆ operator!=() [1/2]

template<class TargetType , class OriginType >
IlsBoolean IlsInvertedRelation< TargetType, OriginType >::operator!= ( Myself rhs)
\short Checks whether the inverted relation is not equal

to another inverted relation.

◆ operator!=() [2/2]

template<class TargetType , class OriginType >
IlsBoolean IlsInvertedRelation< TargetType, OriginType >::operator!= ( OriginType *  rhs)
\short Checks whether the origin-type is not equal to

another origin-type.

◆ operator==()

template<class TargetType , class OriginType >
IlsBoolean IlsInvertedRelation< TargetType, OriginType >::operator== ( Myself rhs)
\short Checks whether the inverted relation is equal to

another inverted relation.

IlsInvertedRelation::Ils2Viewed
friend IlsViewed * Ils2Viewed(OriginType *)
During a notification phase, this member function returns IlsTrue only if the relation has been modif...