|
AndroMeta
2.0.0
|
The central actor base class in an MML program. More...
#include <MMLEntity.h>
Public Member Functions | |
| MMLEntity () | |
| MMLEntity (int id) | |
| MMLEntity (const MMLEntity &entity, bool recursive=false) | |
| MMLEntity (const mvar &v, RestoreOpt opt, MMLRoot *root=0) | |
| MMLEntity (MMLRoot *root) | |
| virtual | ~MMLEntity () |
| virtual void | store (mvar &v) const |
| virtual void | store (mvar &v, bool recursive) const |
| virtual MObject * | clone () const |
| virtual mnode | process (mnode n, uint32_t flags=0) |
| virtual bool | instanceOf (ClassIdType classId) const |
| virtual void | assignId () |
| virtual void | releaseId () |
| virtual mvar | init () |
| void | setId (int id) |
| int | id () const |
| void | setTag (const mvar &tag) |
| const mvar & | tag () const |
| virtual mstr | name () const |
| bool | isThreaded () const |
| void | setThreaded (bool flag) |
| virtual MMessageBuffer * | initPrivateBuffer () |
| virtual MMessageBuffer * | initSharedBuffer () |
| MMessageBuffer * | privateBuffer () const |
| MMessageBuffer * | sharedBuffer () const |
| void | connect (MMLEntity *ent, const mvar &data=undef, const mstr &edgeTag="") |
| void | connect (const mvar &ent, const mvar &data=undef, const mstr &edgeTag="") |
| virtual void | onConnect (MMLEntity *ent, const mstr &edgeTag) |
| void | disconnect (MMLEntity *ent, const mstr &edgeTag) |
| void | disconnect (const mvar &ent, const mstr &edgeTag) |
| void | disconnect (MMLEntity *ent) |
| void | disconnect (const mvar &ent) |
| void | disconnect () |
| void | addLocality (const mstr &attribute, double radius) |
| void | addLocality (const mstr &attribute, double radius, MMLEntity *ent) |
| void | addLocality (const mstr &attribute, double radius, const mvar &ent) |
| size_t | localityCount () const |
| const mstr & | localityAttribute (size_t i) const |
| double | localityRadius (size_t i) const |
| MMLEntity * | localityEntity (size_t i) const |
| void | removeLocality (const mstr &attribute) |
| virtual void | onDisconnect (MMLEntity *ent, const mstr &edgeTag) |
| const mvar & | edgeData (const MMLEntity *ent, const mstr &edgeTag="") const |
| const mvar & | edgeData (const mvar &ent, const mstr &edgeTag="") const |
| void | setEdgeData (const mvar &ent, const mvar &edgeData, const mstr &edgeTag="") |
| void | setEdgeData (const MMLEntity *ent, const mvar &edgeData, const mstr &edgeTag="") |
| virtual void | onAttach (MMLEntity *ent, const mstr &edgeTag) |
| void | detach () |
| virtual void | onDetach (MMLEntity *ent, const mstr &edgeTag) |
| void | signal (MMLEntity *ent, const mstr &edgeTag="") |
| void | signal (const mvar &ent, const mstr &edgeTag="") |
| void | signal (MMLEntity *ent, const mvar &v, const mstr &edgeTag) |
| void | signal (const mvar &ent, const mvar &v, const mstr &edgeTag) |
| void | signalAll () |
| void | signalAll (const mvar &v) |
| size_t | outEdgeCount () const |
| size_t | inEdgeCount () const |
| void | outEdges (mvec &ents, mvec &edgeTags) const |
| void | outEdges (mvec &ents) const |
| mvec | outEdges () const |
| void | setActive (bool flag) |
| bool | isActive () const |
| void | queue () |
| void | queue (MProcTask *task, MProc::SignalMap *signalMap=0, double priority=0, const mtime *time=0) |
| mvar | time () const |
| mvar | interval () const |
| virtual mvar | run () |
| void | setRunAll (bool flag) |
| bool | runAll () const |
| bool | isRunCycle () const |
| virtual mvar | endRun () |
| const mvar & | state () const |
| void | setKept (bool kept) |
| bool | isKept () const |
| void | query (mnode func, mvec &results, bool recursive, bool self, bool error) const |
| mvar | query (mnode func, bool recursive=false, bool self=true, bool error=true) const |
| void | execute (mnode func, bool recursive=false, bool self=true, bool error=true) const |
| void | find (const mstr &name, mvec &results, bool recursive, bool self) const |
| mvar | find (const mstr &name, bool recursive=false, bool self=true) const |
| void | await () |
| bool | await (const mtime &timeout) |
| void | handleEvents () |
| virtual mvar | handleEvent (const mvar &evt) |
| void | send (MMLEntity *ent, const mvar &evt, const mvar &delay) |
| void | send (const mvar &ent, const mvar &evt, const mvar &delay) |
| void | send (MMLEntity *ent, const mvar &evt) |
| void | send (const mvar &ent, const mvar &evt) |
| void | relay (const mvar &evt, const mvar &delay) |
| void | relay (const mvar &evt) |
| void | post (MMLEntity *ent, const mvar &evt, const mvar &delay) |
| void | post (const mvar &ent, const mvar &evt, const mvar &delay) |
| void | post (MMLEntity *ent, const mvar &evt) |
| void | post (const mvar &ent, const mvar &evt) |
| void | log (const mvar &msg, bool concise=true) const |
| void | listen (MMLEntity *ent) |
| void | listen (const mvar &ent) |
| virtual mvar | end () |
| mvar | getLinks (mnode f=mfunc("List")) |
| void | lock () |
| void | unlock () |
| MMLRoot * | rootPtr () |
Static Public Member Functions | |
| static MMLEntity * | ptr (const mvar &v, bool dynamic=false) |
Static Public Attributes | |
| static const ClassIdType | ClassId |
Protected Attributes | |
| mvar | root |
Friends | |
| class | MMLEntity_ |
| class | MMLRoot_ |
The central actor base class in an MML program.
MML entities form the basis of an MML program, providing abstractions which facilitate modeling and simulation: event communication and handling, graph-based chaining and signalling for concurrent execution (using MProc), synchronization methods, time management, recursive querying/execution, and more. MML entities and the "networks" formed by their interconnections are fully storeable and restoreable.
Constructor.
| Meta::MMLEntity::MMLEntity | ( | int | id | ) |
Constructor.
In most cases this variant of the constructor is not needed -- it is primarily used for store/restore.
| Meta::MMLEntity::MMLEntity | ( | const MMLEntity & | entity, |
| bool | recursive = false |
||
| ) |
Copy constructor.
| recursive | If true, recursively copy all connected entities. |
| Meta::MMLEntity::MMLEntity | ( | const mvar & | v, |
| RestoreOpt | opt, | ||
| MMLRoot * | root = 0 |
||
| ) |
Restore constructor.
| root | If non-null, the root to use for this entity, else the default root. |
| Meta::MMLEntity::MMLEntity | ( | MMLRoot * | root | ) |
Ctor with specifed root. Used when multiple roots exist simultaneously.
| virtual Meta::MMLEntity::~MMLEntity | ( | ) | [virtual] |
Destructor.
| void Meta::MMLEntity::addLocality | ( | const mstr & | attribute, |
| double | radius | ||
| ) |
Add a locality attribute to be triggered at root.
| void Meta::MMLEntity::addLocality | ( | const mstr & | attribute, |
| double | radius, | ||
| MMLEntity * | ent | ||
| ) |
Add a locality attribute to be triggered at the specified entity.
| void Meta::MMLEntity::addLocality | ( | const mstr & | attribute, |
| double | radius, | ||
| const mvar & | ent | ||
| ) |
Add a locality attribute to be triggered at the specified entity.
| virtual void Meta::MMLEntity::assignId | ( | ) | [virtual] |
Called when this entity needs to have an id assigned to it. Should not be re-implemented under normal circumstances.
| void Meta::MMLEntity::await | ( | ) |
Block until after completion of this entity's next run.
| bool Meta::MMLEntity::await | ( | const mtime & | timeout | ) |
Block until after completion of this entity's next run or until timeout is reached.
| virtual MObject* Meta::MMLEntity::clone | ( | ) | const [virtual] |
Reimplemented from Meta::MObject.
| void Meta::MMLEntity::connect | ( | MMLEntity * | ent, |
| const mvar & | data = undef, |
||
| const mstr & | edgeTag = "" |
||
| ) |
Form an outward connection to ent.
| ent | The entity to connect to. |
| data | The edge data to attach to this edge. |
| edgeTag | The edge tag |
| void Meta::MMLEntity::connect | ( | const mvar & | ent, |
| const mvar & | data = undef, |
||
| const mstr & | edgeTag = "" |
||
| ) |
Form an outward connection to ent.
| ent | The entity to connect to. |
| data | The edge data to attach to this edge. |
| edgeTag | The edge tag |
| void Meta::MMLEntity::detach | ( | ) |
Detach all inward connections.
| void Meta::MMLEntity::disconnect | ( | MMLEntity * | ent, |
| const mstr & | edgeTag | ||
| ) |
Disconnect outward connection to ent referred to by edgeTag.
| void Meta::MMLEntity::disconnect | ( | const mvar & | ent, |
| const mstr & | edgeTag | ||
| ) |
Disconnect outward connection to ent referred to by edgeTag.
| void Meta::MMLEntity::disconnect | ( | MMLEntity * | ent | ) |
Disconnect all outward connections to ent.
| void Meta::MMLEntity::disconnect | ( | const mvar & | ent | ) |
Disconnect all outward connections to ent.
| void Meta::MMLEntity::disconnect | ( | ) |
Disconnect all outward connections.
| const mvar& Meta::MMLEntity::edgeData | ( | const MMLEntity * | ent, |
| const mstr & | edgeTag = "" |
||
| ) | const |
| const mvar& Meta::MMLEntity::edgeData | ( | const mvar & | ent, |
| const mstr & | edgeTag = "" |
||
| ) | const |
| virtual mvar Meta::MMLEntity::end | ( | ) | [virtual] |
An application-specific method that is called when this entity is reclaimed by root.
Reimplemented in Meta::MDLDomain.
| virtual mvar Meta::MMLEntity::endRun | ( | ) | [virtual] |
Application-specific method called after run() completes and events have been handled.
Reimplemented in Meta::MMLRoot.
| void Meta::MMLEntity::execute | ( | mnode | func, |
| bool | recursive = false, |
||
| bool | self = true, |
||
| bool | error = true |
||
| ) | const |
Similar to query(), execute a function (recursively) on all outward connections but do not gather the results.
| func | The function to run on each entity. |
| recursive | If true, run query recursively. |
| self | true if query should be run on self. |
| error | false if MProcessError's should be suppressed. |
| void Meta::MMLEntity::find | ( | const mstr & | name, |
| mvec & | results, | ||
| bool | recursive, | ||
| bool | self | ||
| ) | const |
| mvar Meta::MMLEntity::find | ( | const mstr & | name, |
| bool | recursive = false, |
||
| bool | self = true |
||
| ) | const |
A common type of query(), (recursively) find all outward connections matching a name.
| name | The name to match. |
| recursive | If true, run query recursively. |
| self | true if find should include self. |
| mvar Meta::MMLEntity::getLinks | ( | mnode | f = mfunc("List") | ) |
Get links in M format.
| f | On output, the links in M format as the specified sequence. |
| virtual mvar Meta::MMLEntity::handleEvent | ( | const mvar & | evt | ) | [virtual] |
Application-specific event handler. Re-implement to determine how this entity responds to events.
Reimplemented in Meta::MDLDomain.
| void Meta::MMLEntity::handleEvents | ( | ) |
| int Meta::MMLEntity::id | ( | ) | const |
Get this entity's id.
| size_t Meta::MMLEntity::inEdgeCount | ( | ) | const |
| virtual mvar Meta::MMLEntity::init | ( | ) | [virtual] |
Application-specific initialization function.
Reimplemented in Meta::MDLDomain.
| virtual MMessageBuffer* Meta::MMLEntity::initPrivateBuffer | ( | ) | [virtual] |
| virtual MMessageBuffer* Meta::MMLEntity::initSharedBuffer | ( | ) | [virtual] |
| virtual bool Meta::MMLEntity::instanceOf | ( | ClassIdType | classId | ) | const [virtual] |
Reimplemented from Meta::MObject.
| mvar Meta::MMLEntity::interval | ( | ) | const |
| bool Meta::MMLEntity::isActive | ( | ) | const |
| bool Meta::MMLEntity::isKept | ( | ) | const |
Set whether this entity is reclaimed by root.
| bool Meta::MMLEntity::isRunCycle | ( | ) | const |
| bool Meta::MMLEntity::isThreaded | ( | ) | const |
| void Meta::MMLEntity::listen | ( | MMLEntity * | ent | ) |
Subscribe to the specified entity's shared buffer.
| void Meta::MMLEntity::listen | ( | const mvar & | ent | ) |
Subscribe to the specified entity's shared buffer.
| const mstr& Meta::MMLEntity::localityAttribute | ( | size_t | i | ) | const |
| size_t Meta::MMLEntity::localityCount | ( | ) | const |
| MMLEntity* Meta::MMLEntity::localityEntity | ( | size_t | i | ) | const |
| double Meta::MMLEntity::localityRadius | ( | size_t | i | ) | const |
| void Meta::MMLEntity::lock | ( | ) |
Lock this entity's general purpose mutex.
| void Meta::MMLEntity::log | ( | const mvar & | msg, |
| bool | concise = true |
||
| ) | const |
Logs entity time, name, and message. Ensures that output does not get interleaved when multiple threads log simultaneously.
| msg | Message to display. |
| concise | Whether to use concise numerics. |
| virtual mstr Meta::MMLEntity::name | ( | ) | const [virtual] |
The name of the entity used for such things as logging, or queries, e.g: find(). By default name is the entity's tag converted to a string.
| virtual void Meta::MMLEntity::onAttach | ( | MMLEntity * | ent, |
| const mstr & | edgeTag | ||
| ) | [virtual] |
Called when forming an outward connection.
| ent | The entity this entity is attaching to. |
| virtual void Meta::MMLEntity::onConnect | ( | MMLEntity * | ent, |
| const mstr & | edgeTag | ||
| ) | [virtual] |
Called when forming an outward connection.
| ent | The entity connected. |
| virtual void Meta::MMLEntity::onDetach | ( | MMLEntity * | ent, |
| const mstr & | edgeTag | ||
| ) | [virtual] |
Called when severing an inward connection.
| ent | The entity this entity is detaching from. |
| virtual void Meta::MMLEntity::onDisconnect | ( | MMLEntity * | ent, |
| const mstr & | edgeTag | ||
| ) | [virtual] |
Called when severing an outward connection.
| ent | The entity disconnected. |
| size_t Meta::MMLEntity::outEdgeCount | ( | ) | const |
| void Meta::MMLEntity::outEdges | ( | mvec & | ents, |
| mvec & | edgeTags | ||
| ) | const |
Get a vector containing the entities and edge tags all outward connections.
| void Meta::MMLEntity::outEdges | ( | mvec & | ents | ) | const |
Get a vector containing the entities of all outward connections. The ents vector contains one entity for each edge even though there may exist multiple edges to that entity.
| mvec Meta::MMLEntity::outEdges | ( | ) | const |
Return a vector containing the entities of all outward connections. The ents vector contains one entity for each edge even though there may exist multiple edges to that entity.
| void Meta::MMLEntity::post | ( | MMLEntity * | ent, |
| const mvar & | evt, | ||
| const mvar & | delay | ||
| ) |
Send an event to the target entity's shared buffer.
| ent | Target entity. |
| evt | The event to send. |
| delay | Delivery time delay. |
| void Meta::MMLEntity::post | ( | const mvar & | ent, |
| const mvar & | evt, | ||
| const mvar & | delay | ||
| ) |
Send an event to the target entity's shared buffer.
| ent | Target entity. |
| evt | The event to send. |
| delay | Delivery time delay. |
| void Meta::MMLEntity::post | ( | MMLEntity * | ent, |
| const mvar & | evt | ||
| ) |
Send an event to the target entity's shared buffer. The delay is the current MML time advance rate (interval).
| ent | Target entity. |
| evt | The event to send. |
| void Meta::MMLEntity::post | ( | const mvar & | ent, |
| const mvar & | evt | ||
| ) |
Send an event to the target entity's shared buffer. The delay is the current MML time advance rate (interval).
| ent | Target entity. |
| evt | The event to send. |
| MMessageBuffer* Meta::MMLEntity::privateBuffer | ( | ) | const |
| virtual mnode Meta::MMLEntity::process | ( | mnode | n, |
| uint32_t | flags = 0 |
||
| ) | [virtual] |
Process method.
Reimplemented from Meta::MObject.
Reimplemented in Meta::MMLGrid, Meta::MMLRoot, Meta::MMLSharedVar, and Meta::MDLDomain.
| static MMLEntity* Meta::MMLEntity::ptr | ( | const mvar & | v, |
| bool | dynamic = false |
||
| ) | [static] |
Convenience method to perform a cast on v to MMLEntity.
| dynamic | If true perform a dynamic cast and ensure type is MMLEntity. |
Reimplemented in Meta::MMLRoot, and Meta::MDLDomain.
| void Meta::MMLEntity::query | ( | mnode | func, |
| mvec & | results, | ||
| bool | recursive, | ||
| bool | self, | ||
| bool | error | ||
| ) | const |
Execute a query (recursively) on all outward connections and gather the results.
| func | The function to run on each entity. |
| results | On completion, a vector of the results of the query. |
| recursive | If true, run query recursively. |
| self | true if query should be run on self. |
| error | false if MProcessError's should be suppressed. |
| mvar Meta::MMLEntity::query | ( | mnode | func, |
| bool | recursive = false, |
||
| bool | self = true, |
||
| bool | error = true |
||
| ) | const |
Execute a query (recursively) on all outward connections and gather the results.
| func | The function to run on each entity. |
| recursive | If true, run query recursively. |
| self | true if query should be run on self. |
| error | false if MProcessError's should be suppressed. |
| void Meta::MMLEntity::queue | ( | ) |
Queue the entity for execution. Normally this is only called once on the top-level entity.
| void Meta::MMLEntity::queue | ( | MProcTask * | task, |
| MProc::SignalMap * | signalMap = 0, |
||
| double | priority = 0, |
||
| const mtime * | time = 0 |
||
| ) |
Queue the entity for execution using MProc::queue() parameters.
| void Meta::MMLEntity::relay | ( | const mvar & | evt, |
| const mvar & | delay | ||
| ) |
Relay an event to this entity's shared buffer.
| evt | The event to send. |
| delay | Delivery time delay. |
| void Meta::MMLEntity::relay | ( | const mvar & | evt | ) |
Relay an event to this entity's shared buffer. The delay is the current MML time advance rate (interval).
| evt | The event to send. |
| virtual void Meta::MMLEntity::releaseId | ( | ) | [virtual] |
Called upon entity destruction to release its id. Should not be re-implemented under normal circumstances.
| void Meta::MMLEntity::removeLocality | ( | const mstr & | attribute | ) |
Remove the specified attribute locality.
| virtual mvar Meta::MMLEntity::run | ( | ) | [virtual] |
Application-specific run method.
Reimplemented in Meta::MMLGrid.
| bool Meta::MMLEntity::runAll | ( | ) | const |
Return the flag that specifies if this entity's run() method called all the time as opposed to only during a run cycle interval.
| void Meta::MMLEntity::send | ( | MMLEntity * | ent, |
| const mvar & | evt, | ||
| const mvar & | delay | ||
| ) |
Send an event to a specific entity. The event gets posted in the target entity's private buffer.
| ent | The target entity. |
| evt | The event to send. |
| delay | Delivery time delay. |
| void Meta::MMLEntity::send | ( | const mvar & | ent, |
| const mvar & | evt, | ||
| const mvar & | delay | ||
| ) |
Send an event to a specific entity. The event gets posted in the target entity's private buffer.
| ent | The target entity. |
| evt | The event to send. |
| delay | Delivery time delay. |
| void Meta::MMLEntity::send | ( | MMLEntity * | ent, |
| const mvar & | evt | ||
| ) |
Send an event to a specific entity. The event gets posted in the target entity's private buffer. The delay is the current MML time advance rate.
| ent | The target entity. |
| evt | The event to send. |
| void Meta::MMLEntity::send | ( | const mvar & | ent, |
| const mvar & | evt | ||
| ) |
Send an event to a specific entity. The event gets posted in the target entity's private buffer. The delay is the current MML time advance rate (interval).
| ent | The target entity. |
| evt | The event to send. |
| void Meta::MMLEntity::setActive | ( | bool | flag | ) |
Set whether or not this entity may be activated.
| void Meta::MMLEntity::setEdgeData | ( | const mvar & | ent, |
| const mvar & | edgeData, | ||
| const mstr & | edgeTag = "" |
||
| ) |
Set the edge data associated with the outward connection to ent.
| void Meta::MMLEntity::setEdgeData | ( | const MMLEntity * | ent, |
| const mvar & | edgeData, | ||
| const mstr & | edgeTag = "" |
||
| ) |
Set the edge data associated with the outward connection to ent.
| void Meta::MMLEntity::setId | ( | int | id | ) |
Explicitly set this entity's id.
| void Meta::MMLEntity::setKept | ( | bool | kept | ) |
Set whether this entity is reclaimed by root. Normally an entity is reclaimed when it has no inward connections. The default is true.
| void Meta::MMLEntity::setRunAll | ( | bool | flag | ) |
Set flag to true to have this entity's run() method called all the time as opposed to only during a run cycle interval. Default is false.
| void Meta::MMLEntity::setTag | ( | const mvar & | tag | ) |
Set tag data. By default, an entity's tag is its id.
| void Meta::MMLEntity::setThreaded | ( | bool | flag | ) |
Set whether this entity potentially uses threaded execution. This is needed because some operations, such as GUI calls, must run on the main thread.
| MMessageBuffer* Meta::MMLEntity::sharedBuffer | ( | ) | const |
| void Meta::MMLEntity::signal | ( | MMLEntity * | ent, |
| const mstr & | edgeTag = "" |
||
| ) |
Signal an outward connection by entity. The signal gets value of its edge data.
| void Meta::MMLEntity::signal | ( | const mvar & | ent, |
| const mstr & | edgeTag = "" |
||
| ) |
Signal an outward connection by entity. The signal gets the value of its edge data.
| void Meta::MMLEntity::signal | ( | MMLEntity * | ent, |
| const mvar & | v, | ||
| const mstr & | edgeTag | ||
| ) |
Signal an outward connection by entity. The signal gets value v.
| void Meta::MMLEntity::signal | ( | const mvar & | ent, |
| const mvar & | v, | ||
| const mstr & | edgeTag | ||
| ) |
Signal an outward connection by entity. The signal gets value v.
| void Meta::MMLEntity::signalAll | ( | ) |
Signal all outward connections.
| void Meta::MMLEntity::signalAll | ( | const mvar & | v | ) |
Signal all outward connections with value v.
| const mvar& Meta::MMLEntity::state | ( | ) | const |
| virtual void Meta::MMLEntity::store | ( | mvar & | v | ) | const [virtual] |
Store this entity to v.
Reimplemented from Meta::MObject.
Reimplemented in Meta::MMLRoot, and Meta::MDLDomain.
| virtual void Meta::MMLEntity::store | ( | mvar & | v, |
| bool | recursive | ||
| ) | const [virtual] |
Store this entity to v.
| recursive | If true, recursively store all connected entities. |
| const mvar& Meta::MMLEntity::tag | ( | ) | const |
Get tag data.
| mvar Meta::MMLEntity::time | ( | ) | const |
| void Meta::MMLEntity::unlock | ( | ) |
Unlock this entity's general purpose mutex.
1.7.6.1