GCS::GElement Class Reference

Everything in the world is an element, they consist of energy, agents and form. More...

#include <GElement.h>

Inheritance diagram for GCS::GElement:

Inheritance graph
[legend]
Collaboration diagram for GCS::GElement:

Collaboration graph
[legend]
List of all members.

Public Types

 ELEMENTCHANGED = 65031
 SENDINFLUENCE = 65032
 RADIATEINFLUENCE = 65033
 PARENTCHANGED = 65034
 INFLUENCERECEIVED = 65035
 ACTIONPERFORMED = 65036
 ENERGYCHANGED = 65037
 FORMCHANGED = 65038
 ELEMENTDATACHANGED = 65039
 CHILDCREATED = 65040
 CHILDREMOVED = 65041
 DELETESELF = 65042
enum  ElementSignalType {
  ELEMENTCHANGED = 65031, SENDINFLUENCE = 65032, RADIATEINFLUENCE = 65033, PARENTCHANGED = 65034,
  INFLUENCERECEIVED = 65035, ACTIONPERFORMED = 65036, ENERGYCHANGED = 65037, FORMCHANGED = 65038,
  ELEMENTDATACHANGED = 65039, CHILDCREATED = 65040, CHILDREMOVED = 65041, DELETESELF = 65042
}

Public Slots

virtual void deleteSelf ()
void receiveInfluence (const GCS::GElementInfluence &)
void performAction (const QString &action, QStringList params, const QString &agent=QString())
void addAgent (GCS::GAgent *agent)
void removeAgent (GCS::GAgent *agent, bool del=FALSE)

Signals

void park ()
void execute (double seconds_elapsed)
void forwardInfluenceInternal (const GCS::GElementInfluence &)
void notifyReparentingInternal (const GCS::GElementID &old_parent, const GCS::GElementID &new_parent, const GCS::GMatrix44 &transformation)
void sendInfluence (const GCS::GElementInfluence &influence, const GCS::GElementID &destination)
void radiateInfluence (const GCS::GElementInfluence &influence, double radius_factor)
void elementChanged (const GCS::GElementID &element)
void parentChanged (const GCS::GElementID &newParent, const GCS::GElementID &oldParent, const GCS::GMatrix44 &transformation)
void influenceReceived (const GCS::GElementInfluence &influence)
void actionPerformed (const QString &action, QStringList params, const QString &agent)
void energyChanged (const GCS::GEnergy &changedEnergy)
void formChanged (const GCS::GForm &changedForm)
void elementDataChanged (const QString &xmlpath)
void childElementCreated (GCS::GElement *newElement)
void childElementRemoved (const GCS::GElementID &childID)

Public Member Functions

 GElement (GObject *object, const QDateTime &park_time=QDateTime::currentDateTime())
const GElementIDgetElementID () const
QDateTime getParkTime () const
bool isParked ()
QList< const GAgent * > getAgents () const
const GObjectgetObject () const
GObjectgetObject ()
QStringList getAvailableActions () const
QString getActionDescription (const QString &action) const
virtual void customEvent (QEvent *event)
void parkElement ()
void executeElement (double seconds_delta_t_offset=0)

Protected Slots

void collectElementChanged ()
void collectSendInfluence (const GCS::GElementInfluence &influence, const GCS::GElementID &destination)
void collectRadiateInfluence (const GCS::GElementInfluence &influence, double radius_factor)
void collectParentChanged (const GCS::GElementID &oldParent, const GCS::GElementID &newParent, const GCS::GMatrix44 &transformation)
void collectInfluenceReceived (const GCS::GElementInfluence &influence)
void collectActionPerformed (const QString &action, QStringList params, const QString &agent)
void collectEnergyChanged (const GCS::GEnergy &changedEnergy)
void collectFormChanged (const GCS::GForm &changedForm)
void collectElementDataChanged (const QString &xmlpath)
void collectChildCreated (GCS::GElement *newElement)
void collectChildRemoved (const GCS::GElementID &childID)
void checkReadyDelete ()

Protected Member Functions

virtual ~GElement ()

Private Attributes

GObjectObject
QList< GAgent * > Agents
QDateTime ParkTime

Detailed Description

Everything in the world is an element, they consist of energy, agents and form.

Author:
Raphael Langerhorst
GElement is the basic building block with which the whole universe is built. It is possible to order elements in a hierarchical structure - like universe - galaxies - solar systems - planets - continents - ... for this structuring child elements are used.

GElement is the interface class for an element that consists of multiple individual classes. Most notably GObject is used to store data.

Every element basically consists of three things: matter/form, energy, behaviour

Matter and form are represented by the GForm, energy is represented by GEnergy. Behaviour is represented by GAgent.

From elements with these three parts everything can be made.

Everything influences each other, so elements are "connected" to each other; this connection can be used for influencing by the behaviour part of the element.


Constructor & Destructor Documentation

GCS::GElement::~GElement (  )  [protected, virtual]

Destructor also deletes the Object and all Agents. If you want to reuse a specific agent, you need to use removeAgent() before deleting the element.

Please note that directly deleting the element must not be done.

Use deleteSelf() instead.

See also:
deleteSelf()

GCS::GElement::GElement ( GObject object,
const QDateTime &  park_time = QDateTime::currentDateTime() 
)

Constructor: GElement takes over ownership of the object; that means that the object is destroyed when the element is destroyed;

Parameters:
park_time sets the time when the element was last parked, be careful with time difference between different computer systems!!


Member Function Documentation

void GCS::GElement::actionPerformed ( const QString &  action,
QStringList  params,
const QString &  agent 
) [signal]

Emitted when the element has received an action through GWE's action interface.

See also:
performAction()

void GCS::GElement::addAgent ( GCS::GAgent agent  )  [slot]

Initializes given agent for this element and adds it to the private list of agents;

Initialization includes connecting signals and slots and setting the agent's Object and Agents member to enable the agent access to these parts of the element.

void GCS::GElement::checkReadyDelete (  )  [protected, slot]

Used by deleteSelf() to check whether the element can already be removed from memory.

If the element is ready to be removed, it will delete itself. If not, the element will schedule another check later with single shot timer.

This eventually results in the element properly deleting itself.

void GCS::GElement::childElementCreated ( GCS::GElement newElement  )  [signal]

Emitted when a child element has been created

Note:
If an agent creates a child and doesn't emit this signal it is NOT guranteed that your element gets recognized by the GWE. You must emit this signal (in the agent) whenever you create a new element.

void GCS::GElement::childElementRemoved ( const GCS::GElementID childID  )  [signal]

Emitted when a child element was removed (deleted).

Note:
This signal should NOT be emitted when the child just changed its parent. Through this signal a parent can cause deletion of an existing child element!
See also:
parentChanged()

void GCS::GElement::collectElementChanged (  )  [protected, slot]

Called whenever anything in the element changes. It causes an elementChanged signal to be emitted in the main event loop.

See also:
customEvent()

void GCS::GElement::customEvent ( QEvent *  event  )  [virtual]

Currently just catches the event for element changes. This is required for thread synchronisation between agent threads and the main event loop. Signals should only go out from the main thread.

void GCS::GElement::deleteSelf (  )  [virtual, slot]

Takes care of deleting this element without further blocking. It makes sure that all agents are parked and then removes itself from memory with QObject::deleteLater()

This slot must be used instead of QObject::deleteLater() and GElement::~GElement()

Note:
thread-safe and non-blocking

void GCS::GElement::elementChanged ( const GCS::GElementID element  )  [signal]

Emitted whenever one of the other signals is emitted as well. This signal is emitted in the main event loop (main thread). All other changed signals are usually not. And it is thus often a few ms later emitted - as soon as the event loop delivers the custom event.

Parameters:
element the ID of this element

void GCS::GElement::elementDataChanged ( const QString &  xmlpath  )  [signal]

Emitted when the agent changed some data in the xml element data object.

See also:
GObject::ElementData

void GCS::GElement::energyChanged ( const GCS::GEnergy changedEnergy  )  [signal]

Emitted when the element's energy has changed.

void GCS::GElement::execute ( double  seconds_elapsed  )  [signal]

Resumes all element-internal processing (execution of agents).

Parameters:
seconds_elapsed tells how much time has passed since parking.
See also:
park(), parkElement(), executeElement()

void GCS::GElement::executeElement ( double  seconds_delta_t_offset = 0  ) 

Emits an execute signal.

Parameters:
seconds_delta_t_offset can be used to compensate time differences between two hosts, e.g. when an element was parked, transfered to another host and executed again. This should be target host time minus source host time.
See also:
execute()

void GCS::GElement::formChanged ( const GCS::GForm changedForm  )  [signal]

Emitted when the element's form has changed.

void GCS::GElement::forwardInfluenceInternal ( const GCS::GElementInfluence  )  [signal]

takes any kind of element influence and passes it on to all agents for processing;

please note that this is a blocking call until all agents have received the influence; some agents might even process the influence fully before returning

QString GCS::GElement::getActionDescription ( const QString &  action  )  const

Note:
if more than one agents provides given action it is not deterministic from which agent the description is provided.
Returns:
description of given action.

QList< const GAgent * > GCS::GElement::getAgents (  )  const

Returns:
a list with all agents (const reference)

QStringList GCS::GElement::getAvailableActions (  )  const

See also:
GAgent::getAvailableActions()

performAction()

Returns:
list of available actions for all agents of this element

const GElementID & GCS::GElement::getElementID (  )  const

returns a read only reference to the element's GElementID;

GObject * GCS::GElement::getObject (  ) 

Returns:
the element's object

const GObject * GCS::GElement::getObject (  )  const

Returns:
the element's object (const pointer)

QDateTime GCS::GElement::getParkTime (  )  const

Returns:
the date and time when the element was last parked
Note:
Be careful here! The element should always be parked BEFORE calling getParkTime()

void GCS::GElement::influenceReceived ( const GCS::GElementInfluence influence  )  [signal]

Emitted when the element receives an influence. This signal might be interesting for the data controller if the actual element is not primarily managed on this server in case of a networked infrastructure.

bool GCS::GElement::isParked (  ) 

Returns true when element is parked. In such a state the element could be safely serialized for example.

Note:
when the element is parked, this means that no agent is executing

void GCS::GElement::notifyReparentingInternal ( const GCS::GElementID old_parent,
const GCS::GElementID new_parent,
const GCS::GMatrix44 transformation 
) [signal]

Forwards the reparent signal from the GWE to all agents. This happens after applying the transformation to the form and before emitting a parentChanged signal.

See also:
reparent()

void GCS::GElement::parentChanged ( const GCS::GElementID newParent,
const GCS::GElementID oldParent,
const GCS::GMatrix44 transformation 
) [signal]

Emitted when the element moves out of its current parent region into another parent region.

Note:
This means a restructuring of the element hierarchy! The GWE might be interested in this.

void GCS::GElement::park (  )  [signal]

Stops all element-internal processing (execution of agents). This is useful for removing the element from memory and keeping it somewhere in a database. If the element needs to be reactivated then this can be performed with executeElement(). By doing so the element measures the time between where it was

Note:
It is not guranteed that this signal returns immediately because it depends on the agent's implementation of GAgent::beginPark().
See also:
execute(), executeElement(), parkElement(), ParkTime

void GCS::GElement::parkElement (  ) 

Emits a park signal.

See also:
park()

void GCS::GElement::performAction ( const QString &  action,
QStringList  params,
const QString &  agent = QString() 
) [slot]

Receives an action from the GWE. It will be forwarded to the respective agent.

Parameters:
action the name of the action to be performed
params the list of parameters for this action
agent optionally give the agent name of which the action should be performed, if this is an empty string the action will be performed in all agents that provide the action.
See also:
GAgent::performAction()

void GCS::GElement::radiateInfluence ( const GCS::GElementInfluence influence,
double  radius_factor 
) [signal]

Connected from all agents' radiateInfluence signals.

void GCS::GElement::receiveInfluence ( const GCS::GElementInfluence  )  [slot]

Takes any kind of element influence. Currently it only emits a forwardInfluence signal which is connected to all the agent's receiveInfluence slot.

See also:
GElement::forwardInfluenceInternal()

void GCS::GElement::removeAgent ( GCS::GAgent agent,
bool  del = FALSE 
) [slot]

Removes given agent from element but does not delete it (by default). all signals and slots between this element and the agent are disconnected. If del is set to TRUE then the agent is also deleted from memory.

void GCS::GElement::sendInfluence ( const GCS::GElementInfluence influence,
const GCS::GElementID destination 
) [signal]

Connected from all agents' sendInfluence signals.


Member Data Documentation

QList<GAgent*> GCS::GElement::Agents [private]

Contains all behaviour for this element, that is, agents.

GObject* GCS::GElement::Object [private]

The elements object, contains energy, form, ...

QDateTime GCS::GElement::ParkTime [private]

Used to measure the elapsed time between element parking and resuming execution. When the element is parked ParkTime is set to the current time. When execution of the element resumes, this attribute can be used to tell how much time has elapsed.

See also:
parkElement(), executeElement()


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