Public Member Functions

fawkes::OneToManyDependency< Provider, Dependant > Class Template Reference

One-to-Many dependency constraint. More...

#include <>>

List of all members.

Public Member Functions

 OneToManyDependency ()
 Constructor.
virtual ~OneToManyDependency ()
 Destructor.
virtual void add (Provider *p)
 Add provider object.
virtual void add (Dependant *d)
 Add dependant object.
virtual void remove (Provider *p)
 Remove provider object.
virtual void remove (Dependant *d)
 Remove a depending object.
virtual bool can_add (Provider *p)
 Check if provider can be added.
virtual bool can_add (Dependant *d)
 Check if dependant can be added.
virtual bool can_remove (Provider *p)
 Check if provider can be removed.
virtual bool can_remove (Dependant *d)
 Check if dependant can be removed.
virtual Provider * provider ()
 Get provider.
virtual std::list< Dependant * > & dependants ()
 Get dependants.

Detailed Description

template<class Provider, class Dependant>
class fawkes::OneToManyDependency< Provider, Dependant >

One-to-Many dependency constraint.

This dependency constraint models a 1-to-n relationship. There is one object called provider, that any number of other objects (dependants) rely on.

The provider is unique and only one provider may exist at any one time. There may be an arbitrary number of dependants. Dependants may only be added if there is already a provider.

Dependants can always be removed. The provider can only be removed if there are no more dependants.

Author:
Tim Niemueller

Definition at line 51 of file dependency_onetomany.h.


Constructor & Destructor Documentation

template<class Provider , class Dependant >
fawkes::OneToManyDependency< Provider, Dependant >::OneToManyDependency (  ) 

Constructor.

Definition at line 78 of file dependency_onetomany.h.

template<class Provider , class Dependant >
fawkes::OneToManyDependency< Provider, Dependant >::~OneToManyDependency (  )  [virtual]

Destructor.

Definition at line 87 of file dependency_onetomany.h.


Member Function Documentation

template<class Provider , class Dependant >
void fawkes::OneToManyDependency< Provider, Dependant >::add ( Provider *  p  )  [virtual]

Add provider object.

This will add the provider to this dependency or throw an exception if there is already a provider.

Parameters:
p provider object to add
Exceptions:
DependencyViolationException thrown, if a second provider is added

Definition at line 101 of file dependency_onetomany.h.

template<class Provider , class Dependant >
void fawkes::OneToManyDependency< Provider, Dependant >::add ( Dependant *  d  )  [virtual]

Add dependant object.

This will add the dependant to this dependency or throw an exception if there is no provider.

Parameters:
d dependant object to add
Exceptions:
DependencyViolationException thrown, if no provider has been set

Definition at line 119 of file dependency_onetomany.h.

template<class Provider , class Dependant >
bool fawkes::OneToManyDependency< Provider, Dependant >::can_add ( Provider *  p  )  [virtual]

Check if provider can be added.

Parameters:
p provider object to add
Returns:
true, if add(p) would succeed, false otherwise

Definition at line 165 of file dependency_onetomany.h.

template<class Provider , class Dependant >
bool fawkes::OneToManyDependency< Provider, Dependant >::can_add ( Dependant *  d  )  [virtual]

Check if dependant can be added.

Parameters:
d dependant object to add
Returns:
true, if add(d) would succeed, false otherwise

Definition at line 177 of file dependency_onetomany.h.

template<class Provider , class Dependant >
bool fawkes::OneToManyDependency< Provider, Dependant >::can_remove ( Dependant *  d  )  [virtual]

Check if dependant can be removed.

Parameters:
d depending object to remove
Returns:
always true

Definition at line 201 of file dependency_onetomany.h.

template<class Provider , class Dependant >
bool fawkes::OneToManyDependency< Provider, Dependant >::can_remove ( Provider *  p  )  [virtual]

Check if provider can be removed.

Parameters:
p provider object to remove
Returns:
true, if remove(p) would succeed, false otherwise

Definition at line 189 of file dependency_onetomany.h.

template<class Provider , class Dependant >
std::list< Dependant * > & fawkes::OneToManyDependency< Provider, Dependant >::dependants (  )  [virtual]

Get dependants.

Returns:
list of dependants.

Definition at line 223 of file dependency_onetomany.h.

template<class Provider , class Dependant >
Provider * fawkes::OneToManyDependency< Provider, Dependant >::provider (  )  [virtual]

Get provider.

Returns:
provider if set, NULL otherwise

Definition at line 212 of file dependency_onetomany.h.

template<class Provider , class Dependant >
void fawkes::OneToManyDependency< Provider, Dependant >::remove ( Provider *  p  )  [virtual]

Remove provider object.

Parameters:
p provider object to remove
Exceptions:
DependencyViolationException thrown, if the provider should be removed while there is still at least one dependant.

Definition at line 136 of file dependency_onetomany.h.

template<class Provider , class Dependant >
void fawkes::OneToManyDependency< Provider, Dependant >::remove ( Dependant *  d  )  [virtual]

Remove a depending object.

Parameters:
d depending object to remove

Definition at line 151 of file dependency_onetomany.h.


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