#include <GElement.h>
Inheritance diagram for GCS::GElement:


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 GElementID & | getElementID () const |
| QDateTime | getParkTime () const |
| bool | isParked () |
| QList< const GAgent * > | getAgents () const |
| const GObject * | getObject () const |
| GObject * | getObject () |
| 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 | |
| GObject * | Object |
| QList< GAgent * > | Agents |
| QDateTime | ParkTime |
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.
| 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.
| 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;
| park_time | sets the time when the element was last parked, be careful with time difference between different computer systems!! |
| 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.
| 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
| void GCS::GElement::childElementRemoved | ( | const GCS::GElementID & | childID | ) | [signal] |
Emitted when a child element was removed (deleted).
| 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.
| 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()
| 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.
| 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.
| 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).
| seconds_elapsed | tells how much time has passed since parking. |
| void GCS::GElement::executeElement | ( | double | seconds_delta_t_offset = 0 |
) |
Emits an execute signal.
| 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. |
| 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 |
| QList< const GAgent * > GCS::GElement::getAgents | ( | ) | const |
| QStringList GCS::GElement::getAvailableActions | ( | ) | const |
| const GElementID & GCS::GElement::getElementID | ( | ) | const |
returns a read only reference to the element's GElementID;
| GObject * GCS::GElement::getObject | ( | ) |
| const GObject * GCS::GElement::getObject | ( | ) | const |
| QDateTime GCS::GElement::getParkTime | ( | ) | const |
| 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.
| 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.
| 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.
| 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
| void GCS::GElement::parkElement | ( | ) |
Emits a park signal.
| 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.
| 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. |
| 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.
| 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.
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.
1.4.7