YGP::RelationN_M< S, T > Class Template Reference

N-to-M relation. More...

Inherits YGP::IRelation.

List of all members.

Public Member Functions

 RelationN_M (const char *name)
virtual ~RelationN_M ()
void relate (const S &source, const T &target)
void relate (const S &source, const std::vector< T > &targets)
void relate (const std::vector< S > &sources, const T &target)
void unrelate (const S &source, const T &target)
void unrelateAll (const S &source)
void unrelateAll (const T &target)
void unrelateAll ()
bool isRelated (const S &owner) const
bool isRelated (const T &object) const
bool isRelated (const S &owner, const T &object) const
const std::vector< T > & getObjects (const S &owner) const
const std::vector< S > & getParents (const T &object) const

Protected Attributes

std::map< S, std::vector< T >
, lessDereferenced< S > > 
objects
std::map< T, std::vector< S >
, lessDereferenced< T > > 
parents


Detailed Description

template<class S, class T>
class YGP::RelationN_M< S, T >

N-to-M relation.

Each object can be connected to various others, which themself can be related to various of the first.


Constructor & Destructor Documentation

template<class S , class T >
YGP::RelationN_M< S, T >::RelationN_M ( const char *  name  )  [inline]

Creates an 1-to-n relation.

Parameters:
name Name of relation Defaultctr

template<class S , class T >
virtual YGP::RelationN_M< S, T >::~RelationN_M (  )  [inline, virtual]

Destructor.


Member Function Documentation

template<class S , class T >
const std::vector<T>& YGP::RelationN_M< S, T >::getObjects ( const S &  owner  )  const [inline]

Returns the childs which are related with the passed object.

Parameters:
owner Parent whose object should be returned
Returns:
T The related object
Remarks:
The object must be related

template<class S , class T >
const std::vector<S>& YGP::RelationN_M< S, T >::getParents ( const T &  object  )  const [inline]

Returns the parents of the passed object.

Parameters:
object Child whose parent should be returned
Returns:
S The related parent
Remarks:
The object must be related

template<class S , class T >
bool YGP::RelationN_M< S, T >::isRelated ( const S &  owner,
const T &  object 
) const [inline]

Checks if the passed object is related to any other (within this relation).

Parameters:
owner Parent which should be checked for relations
object Child which should be checked for being related

template<class S , class T >
bool YGP::RelationN_M< S, T >::isRelated ( const T &  object  )  const [inline]

Checks if the passed object is related to any other (within this relation).

Parameters:
object Child which should be checked for being related

template<class S , class T >
bool YGP::RelationN_M< S, T >::isRelated ( const S &  owner  )  const [inline]

Checks if the passed object is related to any other (within this relation).

Parameters:
owner Parent which should be checked for relations

template<class S , class T >
void YGP::RelationN_M< S, T >::relate ( const std::vector< S > &  sources,
const T &  target 
) [inline]

Connects an object with a bunch of objects, replacing the previously related objects.

Parameters:
sources Parents to relate
target Child to relate with parents

template<class S , class T >
void YGP::RelationN_M< S, T >::relate ( const S &  source,
const std::vector< T > &  targets 
) [inline]

Connects an object with a bunch of objects, replacing the previously related objects.

Parameters:
source Parent to relate
targets Children to relate with parent

template<class S , class T >
void YGP::RelationN_M< S, T >::relate ( const S &  source,
const T &  target 
) [inline]

Connects two objects.

Parameters:
source Parent to relate
target Child to relate with parent

template<class S , class T >
void YGP::RelationN_M< S, T >::unrelate ( const S &  source,
const T &  target 
) [inline]

Disconnects two objects.

Parameters:
source Parent to unrelate
target Child to unrelate from parent

template<class S , class T >
void YGP::RelationN_M< S, T >::unrelateAll (  )  [inline]

Disconnect all objects.

template<class S , class T >
void YGP::RelationN_M< S, T >::unrelateAll ( const T &  target  )  [inline]

Disconnect all parents from an object.

Parameters:
target Parent to unrelate

template<class S , class T >
void YGP::RelationN_M< S, T >::unrelateAll ( const S &  source  )  [inline]

Disconnect all objects from a parent.

Parameters:
source Parent to unrelate


Member Data Documentation

template<class S , class T >
std::map<S, std::vector<T>, lessDereferenced<S> > YGP::RelationN_M< S, T >::objects [protected]

Objects withing the relation; mapping parent objects to a list of child objects.

template<class S , class T >
std::map<T, std::vector<S>, lessDereferenced<T> > YGP::RelationN_M< S, T >::parents [protected]

Parents withing the relation; mapping child objects to a list of parent objects.


The documentation for this class was generated from the following file:

YGP Version 0.9.31 - Generated on Wed Nov 18 11:25:28 2009 by doxygen 1.5.8