#include <Element.h>
Inheritance diagram for Odyssey::Element:
Public Types | |
typedef std::vector< FacetPtr > | FacetList |
typedef ContainerIterator< FacetList > | FacetIterator |
typedef ConstContainerIterator< FacetList > | ConstFacetIterator |
typedef std::map< String, Variable > | UserDataMap |
typedef MapContainerIterator< UserDataMap > | UserDataIterator |
typedef ConstMapContainerIterator< UserDataMap > | ConstUserDataIterator |
typedef std::vector< Element * > | ChildList |
typedef ContainerIterator< ChildList > | ChildIterator |
typedef ConstContainerIterator< ChildList > | ConstChildIterator |
Public Member Functions | |
Element () | |
Constructs an empty Element with an empty name. | |
void | setName (const String &name) |
Sets the name for this element. | |
const String & | getName () const |
Returns the name of the Element. | |
Element * | getParent () const |
Returns the parent of this Element, or 0 if there isn't one. | |
void | createState (const String &name) |
Creates a new state with the given name, or fails silently if the state already exists. | |
void | removeState (const String &name) |
Removes the state with the given name. | |
void | removeState (const String &name, const String &newCurrent) |
Removes the state with the given name. | |
void | setCurrentState (const String &name) |
Sets the current state to the state with the given name. | |
boost::optional< String > | getCurrentState () const |
Returns the name of the current state. | |
void | clearStates () |
Removes all the currently contained states (except the default state). | |
void | addStateListener (StateListener *listener) |
Adds a new element state listener. | |
void | removeStateListener (StateListener *listener) |
Removes the state listener from the element. | |
void | clearStateListeners () |
Removes all the state listeners. | |
void | _notifyStateListeners (const String &newState) |
Internal method for signalling the state listeners. | |
Facet * | addFacet (FacetPtr facet) |
Add a new facet to this Element. | |
void | setFacet (size_t index, FacetPtr facet) |
Sets the facet at the given index. | |
Facet * | addDynamicFacet (const String &typeID) |
Uses dynamic class construction to add a new facet. | |
void | setDynamicFacet (size_t index, const String &typeID) |
Uses dynamic class construction to set the facet at the given index. | |
FacetPtr | getFacet (size_t index) const |
Returns the facet at the given index. | |
void | sendMessageToFacet (size_t index, const Message &msg) |
Send a message to the given facet, and doesn't return until it is processed. | |
void | removeFacet (size_t index) |
Removed the given facet. | |
void | removeFacet (Facet *facet) |
Removed the given facet. | |
void | clearFacets () |
Clears all facets from this Element. | |
size_t | getFacetCount () const |
Returns the number of facets. | |
FacetIterator | getFacetIterator () |
Returns an iterator over the Element's facets. | |
ConstFacetIterator | getFacetIterator () const |
Returns an iterator over the Element's facets. | |
ElementPtr | createChild (const String &name) |
Adds a new child with the given name in the ModelManager. | |
ElementPtr | createChild (const String &typeID, const String &name) |
Adds a new child with the given typeID and name in the ModelManager. | |
size_t | addChild (Element *element) |
Adds a child to Element. | |
size_t | addChild (const String &name) |
Adds a child with the given name to this Element. | |
size_t | addChild (size_t index) |
Adds a child with the given index to this Element. | |
void | removeChild (Element *element) |
Removes a child from this Element. | |
void | removeChild (size_t index) |
Removes a child from the index. | |
bool | containsChild (const String &name) const |
Check if a child with this name exists in this Element. | |
Element * | getChild (size_t index) const |
Returns the child at the given internal index. | |
void | clearChildren () |
Removes all the children from this Element. | |
size_t | getChildCount () const |
Returns the number of children. | |
ChildIterator | getChildIterator () |
Returns an iterator over the Element's children. | |
ConstChildIterator | getChildIterator () const |
Returns an iterator over the Element's children. | |
void | setUserData (const String &name, const Variable &value) |
Sets the user data for a given name. | |
Variable | getUserData (const String &name) const |
Returns the value of the variable with the given name. | |
void | removeUserData (const String &name) |
Removes the variable with the given name. | |
void | clearUserData () |
Clears all the user data for this Element. | |
bool | containsUserData (const String &name) const |
Returns true if the user data entry exists. | |
UserDataIterator | getUserDataIterator () |
Returns an iterator over all of the user data of the Element. | |
ConstUserDataIterator | getConstUserDataIterator () const |
Returns an iterator over all of the user data of the Element. | |
void | create () |
Creates the Element and its facets. | |
void | destroy () |
Destroys the element and its facets. | |
bool | isCreated () |
This function returns true if the call the create completed successfully. | |
void | setActive (bool active=true, bool cancelUpdates=true) |
Activates or deactivates the element. | |
bool | getActive () const |
Returns the current status of the Element. True means active. | |
virtual void | update () |
Updates the element. | |
void | _notifyUpdate () |
If active, this function will notify the ElementManager for updates. | |
MessageQueue & | getMessageQueue () |
Gives access to this element's internal message queue. | |
virtual bool | onAdding (Manager< ElementPtr > &) const |
virtual bool | onRemoving (Manager< ElementPtr > &) const |
Static Public Member Functions | |
static void | createAll (ElementPtr element) |
Creates all elements in the hierarchy. | |
static void | createAll (Element *element) |
static void | destroyAll (ElementPtr element) |
Destroys all elements in the hierarchy. | |
static void | destroyAll (Element *element) |
static void | setActiveAll (ElementPtr element, bool active) |
Sets the active state of all elements in the hierarchy. | |
static void | setActiveAll (Element *element, bool active) |
static void | sendMessageToAll (ElementPtr element, const Message &msg) |
Sends a message to all elements in the hierarchy. | |
static void | sendMessageToAll (Element *element, const Message &msg) |
static void | postMessageToAll (ElementPtr element, const Message &msg) |
Posts a message to all elements in the hierarchy. | |
static void | postMessageToAll (Element *element, const Message &msg) |
Protected Member Functions | |
virtual void | onMessagePosted () |
This event occurs when a message is posted to the message queue. | |
virtual std::pair< bool, Variable > | onMessage (const Message &msg) |
This event is called when a message needs to be handled (it is processed). | |
virtual void | onRemoved (MessageQueue &queue) |
This event is called when this listener is removed as a listener from the message queue. | |
virtual void | onNotify (Model *model) |
ElementState * | getElementState () const |
Protected Attributes | |
String | _name |
bool | _active |
bool | _created |
MessageQueue | _queue |
Element * | _parent |
ChildList | _children |
std::set< Element * > | _childSet |
Friends | |
class | ElementManager |
class | ElementBuilder |
Classes | |
class | ElementState |
class | StateListener |
This class represents a single entity that exists in the simulation. It is made up of Facets, can reference Models, and store arbitrary, user-defined data.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Constructs an empty Element with an empty name.
|
|
Internal method for signalling the state listeners.
|
|
If active, this function will notify the ElementManager for updates.
|
|
Adds a child with the given index to this Element. This function uses the index to lookup an Element in the ElementManager.
|
|
Adds a child with the given name to this Element. This function uses the given name to lookup an Element in the ElementManager.
|
|
Adds a child to Element.
|
|
Uses dynamic class construction to add a new facet.
|
|
Add a new facet to this Element.
|
|
Adds a new element state listener.
|
|
Removes all the children from this Element.
|
|
Clears all facets from this Element.
|
|
Removes all the state listeners.
|
|
Removes all the currently contained states (except the default state).
|
|
Clears all the user data for this Element.
|
|
Check if a child with this name exists in this Element.
|
|
Returns true if the user data entry exists.
|
|
Creates the Element and its facets. This function creates the Element, which forwards this to all facets. This does not set the Element to active, nor does it cause an update request. |
|
|
|
Creates all elements in the hierarchy. This function traverses the hierarchy of Elements and children in order and creates each one.
|
|
Adds a new child with the given typeID and name in the ModelManager.
|
|
Adds a new child with the given name in the ModelManager.
|
|
Creates a new state with the given name, or fails silently if the state already exists. This function will create a new state with the given name, or if the state already exists it will do nothing. In the case that a new state is created, and there is no other states but the default state, this newly-created state becomes the current state of the Element.
|
|
Destroys the element and its facets. This function destroys the Element, which forwards this call to all the facets. This does not remove any facets or data, nor does it affect any statuses within the element except:
|
|
|
|
Destroys all elements in the hierarchy. This function traverses the hierarchy of Elements and children in order and destroys each one.
|
|
Returns the current status of the Element. True means active.
|
|
Returns the child at the given internal index.
|
|
Returns the number of children.
|
|
Returns an iterator over the Element's children.
|
|
Returns an iterator over the Element's children.
|
|
Returns an iterator over all of the user data of the Element.
|
|
Returns the name of the current state. This function uses the boost optional argument to return the name of the current state. The optional is not initialized if the Element contains only the default state. In that case !getCurrentState would be true. |
|
|
|
Returns the facet at the given index.
|
|
Returns the number of facets.
|
|
Returns an iterator over the Element's facets.
|
|
Returns an iterator over the Element's facets.
|
|
Gives access to this element's internal message queue.
|
|
Returns the name of the Element.
|
|
Returns the parent of this Element, or 0 if there isn't one.
|
|
Returns the value of the variable with the given name.
|
|
Returns an iterator over all of the user data of the Element.
|
|
This function returns true if the call the create completed successfully.
|
|
|
|
This event is called when a message needs to be handled (it is processed).
Implements Odyssey::MessageListener. |
|
This event occurs when a message is posted to the message queue.
Implements Odyssey::MessageListener. |
|
Implements Odyssey::ModelListener. |
|
This event is called when this listener is removed as a listener from the message queue.
Implements Odyssey::MessageListener. |
|
|
|
|
|
Posts a message to all elements in the hierarchy. This function traverses the hierarchy of Elements and children in order and posts a message to each one.
|
|
Removes a child from the index.
|
|
Removes a child from this Element.
|
|
Removed the given facet.
|
|
Removed the given facet.
|
|
Removes the state with the given name. This function removes the given state, and instates the new current state as the one with the given name.
|
|
Removes the state with the given name. The state with the given name is removed from this Element. The current state will be the next available state, or the default is none is found. The order of the states is undefined.
|
|
Removes the state listener from the element.
|
|
Removes the variable with the given name.
|
|
|
|
Sends a message to all elements in the hierarchy. This function traverses the hierarchy of Elements and children in order and sends a message to each one.
|
|
Send a message to the given facet, and doesn't return until it is processed.
|
|
Activates or deactivates the element. This function sets the element to active or deactive. Active elements are the elements that are being simulated.
|
|
|
|
Sets the active state of all elements in the hierarchy. This function traverses the hierarchy of Elements and children in order and sets each active state each one.
|
|
Sets the current state to the state with the given name.
|
|
Uses dynamic class construction to set the facet at the given index.
|
|
Sets the facet at the given index.
|
|
Sets the name for this element.
|
|
Sets the user data for a given name. This function sets the variable for the given name to the given value.
|
|
Updates the element.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|