GWE::GweController Class Reference

Base class for G World Engine (GWE) controller implementations. More...

#include <GweController.h>

Inheritance diagram for GWE::GweController:

Inheritance graph
[legend]
Collaboration diagram for GWE::GweController:

Collaboration graph
[legend]
List of all members.

Public Slots

virtual void executeOpenElement (const GCS::GElementID &id)
virtual void radiateInfluence (const GCS::GElementInfluence &influence, double radius_factor)
virtual void routeInfluence (const GCS::GElementInfluence &influence, const GCS::GElementID &destination)
virtual void removeElementWithNoEnergyLeft (const GCS::GEnergy &changedEnergy)
virtual void shutdown ()

Signals

void quit ()

Public Member Functions

 GweController (GDataController *data, GInformationInterface *info, QObject *parent=0)
virtual ~GweController ()
virtual GDataControllergetDataController ()
virtual const GDataControllergetDataController () const
virtual GInformationInterfacegetInformationInterface ()
virtual GActionInterfacegetActionInterface ()
virtual void performAction (const GCS::GElementID &element, const QString &action, QStringList params, const QString &agent=QString())
virtual QStringList getAvailableActions (const GCS::GElementID &element) const
virtual QString getActionDescription (const GCS::GElementID &element, const QString &action) const

Protected Slots

virtual void connectBasicElementSignals (const GCS::GElementID &id)

Protected Member Functions

virtual QList< GCS::GElement * > findInRange (GCS::GElement *source, double range_factor, unsigned max_traverse_children=0, unsigned max_traverse_parents=1)

Protected Attributes

GDataControllerData
GInformationInterfaceInformationInterface

Detailed Description

Base class for G World Engine (GWE) controller implementations.

GweController GweController.h

Author:
Raphael Langerhorst
GweController defines the interface for the GWE controller implementation. The GWEs single purpose is persistent element management and thus has a very slim and effective interface definition. Whether this implementation is a dynamic network distributed hierarchical server structure with database backend or a simple local implementation does not matter.

Note:
Some documentation given here on this class (or interface) depends on the actual implementation that is used; the implementation is "supposed" to do what the documentation of the method says.
Todo:
use exceptions as they provide a better way for failure description.(??) talk about this on the mailing list first!!


Constructor & Destructor Documentation

GWE::GweController::GweController ( GDataController data,
GInformationInterface info,
QObject *  parent = 0 
)

Constructor.

Parameters:
data the GDataController used

GWE::GweController::~GweController (  )  [virtual]

Virtual destructor to allow clean memory management with derived classes.


Member Function Documentation

void GWE::GweController::connectBasicElementSignals ( const GCS::GElementID id  )  [protected, virtual, slot]

Connects the following element signals in a standard way, data is the GDataController that is used.

Reimplemented in GWE::GweAdvancedController.

QList< GCS::GElement * > GWE::GweController::findInRange ( GCS::GElement source,
double  range_factor,
unsigned  max_traverse_children = 0,
unsigned  max_traverse_parents = 1 
) [protected, virtual]

Uses the data controller to find all elements that are in the range of the given source element. Elements in range are simply all elements that touch each other.

This method is usually used to find all elements that are affected by an influence.

If the source element has no form, the form of the parent element is used as boundary, until a element with a form is found or traversal count reaches max_depth_parent.

Normally max_traverse_parents is not set to anything larger than 1. If it is necessary it most likely because of a bad element design. Still, it can be useful in some cases.

Parameters:
source The element that defines the range of affected elements.
max_traverse_children Sets the maximum element hierarchy traversal limit in the direction of children; 0 means no children at all, 1 means all direct children, ...
max_traverse_parents Sets the maximum element hierarchy traversal limit in the direction of parents; 0 means no parents (not even the parent of the source element!), 1 means including the direct parent; a higher value than 1 only makes sense if neither the source nor the parent element have a form attribute. The real maximum of parent traverses is defined by the minimum of this parameter and the number of traversals to the first parent with a form and the number of traversals to the root element.
Returns:
List of elements that overlap with their form with the source element.

QString GWE::GweController::getActionDescription ( const GCS::GElementID element,
const QString &  action 
) const [virtual]

Returns:
description of given action

Implements GWE::GActionInterface.

GActionInterface * GWE::GweController::getActionInterface (  )  [virtual]

The Action interface is usually the controller itself.

Returns:
Action interface of this controller.

QStringList GWE::GweController::getAvailableActions ( const GCS::GElementID element  )  const [virtual]

Returns:
list of available actions for given element.
See also:
GCS::GElement::getAvailableActions()

Implements GWE::GActionInterface.

const GDataController * GWE::GweController::getDataController (  )  const [virtual]

Returns:
The data controller used, read-only.

GDataController * GWE::GweController::getDataController (  )  [virtual]

Returns:
The data controller used.

GInformationInterface * GWE::GweController::getInformationInterface (  )  [virtual]

Returns:
Information interface of this controller.

void GWE::GweController::performAction ( const GCS::GElementID element,
const QString &  action,
QStringList  params,
const QString &  agent = QString() 
) [virtual]

Performs given action for given element.

See also:
GCS::GElement::performAction()

Implements GWE::GActionInterface.

void GWE::GweController::quit (  )  [signal]

Emitted when the GWE Server should shutdown.

See also:
shutdown()

void GWE::GweController::radiateInfluence ( const GCS::GElementInfluence influence,
double  radius_factor 
) [virtual, slot]

Forwards given influence to all elements that are near to the sender() of this signal.

See also:
GElement::radiateInfluence()

void GWE::GweController::removeElementWithNoEnergyLeft ( const GCS::GEnergy changedEnergy  )  [virtual, slot]

Checks if given element (sender()) has an energy amount of 0 in which case it is deleted.

Usually this slot can be connected to the energyChanged() signal of an element.

void GWE::GweController::routeInfluence ( const GCS::GElementInfluence influence,
const GCS::GElementID destination 
) [virtual, slot]

Routes an influence from an element to given destination.

See also:
GElement::routeInfluence()

void GWE::GweController::shutdown (  )  [virtual, slot]

Shuts down the whole World Engine and does all required cleanup beforehand. It is highly recommended to call this slot before shutting down the application.

At the end the quit signal is emitted. In this state all cleanup and shutdown is down and the application can safely quit.

See also:
quit()


Member Data Documentation

GDataController* GWE::GweController::Data [protected]

Every GWE Controller needs to have a data controller anyway, so it is already present in this base class and can be used be derived controllers.

Note:
the data controller is passed in the constructor

GInformationInterface* GWE::GweController::InformationInterface [protected]

The Information interface of this controller.

Note:
the InformationInterface is passed in the constructor


The documentation for this class was generated from the following files:
Generated on Thu Nov 16 07:49:37 2006 for G System by  doxygen 1.4.7