ot::Node Class Reference
[Core Classes]
The basic superclass for all nodes.
More...
#include <Node.h>
Inheritance diagram for ot::Node:

Attributes Control Interface | |
| This set of methods allows to manipulate the attributes of a node in a safe and abstract manner. These methods operate on the attributes of the underlying XML element. Whenever an attribute changes the implementation of the node should take care to update the XML elements attributes as well. | |
| const std::string | get (const std::string &key) const |
| int | get (const std::string &key, int *value, int len=1) const |
| int | get (const std::string &key, float *value, int len=1) const |
| int | get (const std::string &key, double *value, int len=1) const |
| void | put (const std::string &key, const std::string &value) |
| void | remove (const std::string &key) |
| void | put (const std::string &key, const int value) |
| void | put (const std::string &key, const float value) |
| void | put (const std::string &key, const double value) |
| void | put (const std::string &key, const int *value, int len) |
| void | put (const std::string &key, const float *value, int len) |
| void | put (const std::string &key, const double *value, int len) |
Public Types | |
| OK = 0 | |
| GRAPH_CONSTRAINT | |
| READONLY | |
| CONTEXT_ERROR | |
| NOT_FOUND | |
| enum | error { OK = 0, GRAPH_CONSTRAINT, READONLY, CONTEXT_ERROR, NOT_FOUND } |
Public Member Functions | |
| virtual | ~Node () |
| const std::string & | getType () const |
| const std::string & | getName () const |
| Context * | getContext () const |
| virtual int | isNodePort () |
Graph Navigation Interface | |
This set of methods allows to manipulate the data flow graph in a rather safe manner. | |
| Node * | getParent () |
| unsigned int | countChildren () |
| Node * | getChild (unsigned int index) |
| error | addChild (Node &child) |
| error | removeChild (Node &child) |
| unsigned int | countPorts () |
| NodePort * | getPort (const std::string &name, unsigned int index=0) |
| NodePort * | getPort (unsigned int index) |
| error | addPort (const std::string &name) |
| error | removePort (const std::string &name) |
| error | removePort (NodePort &port) |
| error | removePort (unsigned int index) |
EventGenerator & EventObserver Interface | |
This is the classic event passing interface, working from children nodes up to parent nodes. A child node creates a new event and its parent node is automatically notified of the event. The type of an event is of class Event. | |
| virtual int | isEventGenerator () |
| virtual void | onEventGenerated (Event &event, Node &generator) |
| void | updateObservers (Event &data) |
EventQueue Interface | |
The EventQueue interface allows access to a queue of events, ordered by their timestamps, with the latest event coming first, at slot 0. This works from parents to children, i.e. parents query their children for a certain event in the queue. | |
| virtual int | isEventQueue () |
| virtual Event & | getEvent (unsigned int index=0) |
| virtual Event & | getEventNearTime (double time) |
| virtual unsigned int | getSize () |
TimeDependend Interface | |
The TimeDependend Interface allows access to a continous function of events in time. It also works from parents to children, i.e. a parent queries a child for the event at a given point in time. | |
| virtual int | isTimeDependend () |
| virtual Event & | getEventAtTime (double time) |
Protected Member Functions | |
| virtual void | setParent (void *parElement) |
| void | addReference (Node *reference) |
| void | removeReference (Node *reference) |
| Node () | |
Protected Attributes | |
| void * | parent |
| NodeVector | references |
| std::string | name |
| std::string | type |
Friends | |
| class | Context |
| class | ConfigurationParser |
| class | RefNode |
| class | XMLWriter |
Detailed Description
The basic superclass for all nodes.It implements several interfaces necessary to deal with nodes. Moreover it provides the link to the underlying XML Document tree and stores information such as the type (i.e. element name) and a name (i.e. unique ID) of the node.
- Author:
- Gerhard Reitmayr
Definition at line 92 of file Node.h.
Member Enumeration Documentation
| enum ot::Node::error |
error type returned by some graph manipulation functions
Constructor & Destructor Documentation
| ot::Node::Node | ( | ) | [protected] |
empty basic constructor.
The constructors of any nodes should be protected to avoid application code to directly construct new instances. Any new nodes should be generated via valid API calls such as Context::createNode() to ensure that internal data is correct. Any NodeFactories needing access should be declared friend classes of the nodes.
Definition at line 90 of file Node.cxx.
References parent.
| ot::Node::~Node | ( | ) | [virtual] |
Member Function Documentation
| Node::error ot::Node::addChild | ( | Node & | child | ) |
adds a new child to the direct children of the node.
This method will only work, if it does not violate any rules for the graph.
- Parameters:
-
child the new child node to add
- Returns:
- error code describing outcome of the operation
Definition at line 241 of file Node.cxx.
References GRAPH_CONSTRAINT, OK, and parent.
Referenced by addPort().
| Node::error ot::Node::addPort | ( | const std::string & | name | ) |
creates and adds a new child NodePort object of the given name.
It will also only work, if it does not violate any rules for the graph.
- Parameters:
-
name the name of the NodePort
- Returns:
- error code describing outcome of the operation
Definition at line 440 of file Node.cxx.
References addChild(), ot::Context::createNode(), getContext(), ot::Context::getRootNamespace(), GRAPH_CONSTRAINT, parent, and ot::ud_node.
| void ot::Node::addReference | ( | Node * | reference | ) | [protected] |
adds a reference node to the list of references.
Parents of references need to be updated in case of an event generated.
- Parameters:
-
reference the reference node to add
Definition at line 139 of file Node.cxx.
References references.
| unsigned int ot::Node::countChildren | ( | ) |
returns the number of children that are not wrapped, nor wrapper nodes.
That is the direct children a node may work with.
- Returns:
- unsigned number of children
Reimplemented in ot::ConfigNode.
Definition at line 204 of file Node.cxx.
References isNodePort(), parent, and ot::ud_node.
Referenced by ot::ConfigNode::countChildren(), and ot::MergeNode::onEventGenerated().
| unsigned int ot::Node::countPorts | ( | ) |
returns the number of NodePorts present on this Node.
This is the number of NodePorts actually used, not the total number possible by the content definition.
- Returns:
- unsigned number of NodePorts
Definition at line 322 of file Node.cxx.
References isNodePort(), parent, and ot::ud_node.
| int ot::Node::get | ( | const std::string & | key, | |
| double * | value, | |||
| int | len = 1 | |||
| ) | const |
parses a stored entry into an array of doubles.
It assumes that the doubles are separated by spaces. It returns the number of actually converted doubles.
- Parameters:
-
key the key of the entry to parse value pointer to the array of doubles to store the parsed values len the length of the array, default 1 to use it for a single double only
- Returns:
- number of actually parsed values
Definition at line 721 of file Node.cxx.
References get().
| int ot::Node::get | ( | const std::string & | key, | |
| float * | value, | |||
| int | len = 1 | |||
| ) | const |
parses a stored entry into an array of floats.
It assumes that the floats are separated by spaces. It returns the number of actually converted floats.
- Parameters:
-
key the key of the entry to parse value pointer to the array of integers to store the parsed values len the length of the array, default 1 to use it for a single float only
- Returns:
- number of actually parsed values
Definition at line 707 of file Node.cxx.
References get().
| int ot::Node::get | ( | const std::string & | key, | |
| int * | value, | |||
| int | len = 1 | |||
| ) | const |
parses a stored entry into an array of integers.
It assumes that the integers are separated by spaces. It returns the number of actually converted integers.
- Parameters:
-
key the key of the entry to parse value pointer to the array of integers to store the parsed values len the length of the array, default 1 to use it for a single int only
- Returns:
- number of actually parsed values
Definition at line 693 of file Node.cxx.
References get().
| const std::string ot::Node::get | ( | const std::string & | key | ) | const |
returns a value stored in the map
- Parameters:
-
key the key the value is for
- Returns:
- the string value or an empty string, if the key is not found
Definition at line 559 of file Node.cxx.
References getContext(), ot::Context::getRootNamespace(), and parent.
Referenced by ot::SpeechModule::createNode(), get(), and ot::MergeNode::onEventGenerated().
| Node * ot::Node::getChild | ( | unsigned int | index | ) |
returns a child indicated by the index.
This only returns children that are not wrapped or Wrapper nodes themselves.
- Parameters:
-
index unsigned number => 0 and < countChildren()
- Returns:
- pointer to the child node or NULL if index is out of range.
Reimplemented in ot::ConfigNode.
Definition at line 283 of file Node.cxx.
References isNodePort(), parent, and ot::ud_node.
Referenced by ot::ConfigNode::getChild(), ot::Transformation::getEvent(), ot::Transformation::getEventAtTime(), ot::Transformation::getEventNearTime(), ot::Transformation::getSize(), ot::Transformation::isEventGenerator(), ot::Transformation::isEventQueue(), ot::Transformation::isTimeDependend(), and ot::FilterNode::onEventGenerated().
| Context * ot::Node::getContext | ( | ) | const |
| virtual Event& ot::Node::getEvent | ( | unsigned int | index = 0 |
) | [inline, virtual] |
returns a stored event by index.
The index starts with 0 for the latest event and goes back in time with increasing index.
- Parameters:
-
index index of the desired event, if no index is given the latest is returned.
- Returns:
- reference to the value of the event.
Reimplemented in ot::EventQueueNode, ot::Transformation, and ot::RefNode.
Definition at line 443 of file Node.h.
References ot::Event::null.
Referenced by ot::Transformation::getEvent(), and ot::FilterNode::onEventGenerated().
| virtual Event& ot::Node::getEventAtTime | ( | double | time | ) | [inline, virtual] |
returns the event of the time dependend function at a given point in time.
- Parameters:
-
time point in time in milliseconds since 1.1.1970
- Returns:
- reference to the event value
Reimplemented in ot::Transformation, and ot::RefNode.
Definition at line 488 of file Node.h.
References ot::Event::null.
Referenced by ot::Transformation::getEventAtTime().
| virtual Event& ot::Node::getEventNearTime | ( | double | time | ) | [inline, virtual] |
returns the event closest to a given point in time.
- Parameters:
-
time the point in time in milliseconds since 1.1.1970
- Returns:
- reference to the value of the event.
Reimplemented in ot::EventQueueNode, ot::Transformation, and ot::RefNode.
Definition at line 451 of file Node.h.
References ot::Event::null.
Referenced by ot::Transformation::getEventNearTime().
| const std::string& ot::Node::getName | ( | ) | const [inline] |
| Node * ot::Node::getParent | ( | ) |
returns a pointer to the parent node of the current node.
This can be a wrapper node to mark a certain input port of a real node. In this case, getting the wrapper nodes parent will yield the true parent. The root node will return NULL, because it has no parent.
- Returns:
- pointer to parent node
Definition at line 158 of file Node.cxx.
References parent, and ot::ud_node.
| NodePort * ot::Node::getPort | ( | unsigned int | index | ) |
returns a NodePort child object by index.
The order of the NodePorts is not fixed but may depend on the configuration file used.
- Parameters:
-
index unsigned number => 0 and < countWrappedChildren
- Returns:
- pointer to the child NodePort or NULL if index is out of range.
Definition at line 401 of file Node.cxx.
References isNodePort(), parent, and ot::ud_node.
| NodePort * ot::Node::getPort | ( | const std::string & | name, | |
| unsigned int | index = 0 | |||
| ) |
returns a NodePort child object indexed by Name.
If the NodePort is not present, NULL is returned.
- Parameters:
-
name the element name of the NodePort index the index of the required port within all ports with the same name
- Returns:
- pointer to the child NodePort or NULL if none of this name is present.
Definition at line 357 of file Node.cxx.
References getContext(), ot::Context::getRootNamespace(), isNodePort(), parent, and ot::ud_node.
Referenced by ot::MergeNode::onEventGenerated(), and removePort().
| virtual unsigned int ot::Node::getSize | ( | ) | [inline, virtual] |
returns the number of stored events.
- Returns:
- number of stored events.
Reimplemented in ot::EventQueueNode, ot::Transformation, and ot::RefNode.
Definition at line 458 of file Node.h.
Referenced by ot::Transformation::getSize(), and ot::FilterNode::onEventGenerated().
| const std::string& ot::Node::getType | ( | ) | const [inline] |
returns the type of the node, that is the element name of the underlying configuration element.
An implementation can then use this information to down cast a node reference or pointer to the correct class.
- Returns:
- string containing the node type
Definition at line 263 of file Node.h.
Referenced by ot::ARToolKitPlusModule::newVideoFrame(), ot::MergeNode::onEventGenerated(), and ot::ButtonOpNode::onEventGenerated().
| virtual int ot::Node::isEventGenerator | ( | ) | [inline, virtual] |
tests for EventGenerator interface being implemented.
This has to be overriden in classes that subclass EventGenerator. Due to inheritance raints it cannot be done automatically.
- Returns:
- a pointer to the EventGenerator interface, or NULL if it is not implemented
Reimplemented in ot::ButtonFilterNode, ot::ButtonHoldFilterNode, ot::ButtonOpNode, ot::CallbackNode, ot::ConfidenceFilterNode, ot::ConfidenceSelectNode, ot::ConsoleSink, ot::ConsoleSource, ot::ElasticFilterNode, ot::EventQueueNode, ot::EventUtilityNode, ot::FileSink, ot::FileSource, ot::FilterNode, ot::GroupGateNode, ot::ActiveGateNode, ot::MergeNode, ot::PositionFilterNode, ot::RangeFilterNode, ot::SelectionNode, ot::ThresholdFilterNode, ot::TimeGateNode, ot::Transformation, ot::RefNode, ot::TestSource, ot::ARTDataTrackerSource, ot::ARToolKitMultiMarkerSource, ot::ARToolKitSource, ot::CyberMouseSource, ot::DynaSightSource, ot::FastTrakSource, ot::FOBSource, ot::GPSDirectionSource, ot::GPSGarminAltitude, ot::GPSGarminCompass, ot::GPSInfoSource, ot::GPSSource, ot::InterSenseSource, ot::LinmouseSource, ot::MagicYSource, ot::MulticastInputSource, ot::P5GloveSource, ot::ParButtonSource, ot::SpaceMouseSource, ot::SpeechSource, ot::TargusSource, ot::UbisenseSource, ot::UltraTrakSource, ot::WacomGraphireSource, ot::XSensSource, ot::CORBASink, ot::CORBASource, ot::DwarfSink, ot::DwarfSource, ot::NetworkSink, ot::NetworkSource, ot::TCPSink, ot::VRPNSink, ot::VRPNSource, and ot::QtMouseEventSinkBase.
Definition at line 391 of file Node.h.
Referenced by ot::Transformation::isEventGenerator(), and updateObservers().
| virtual int ot::Node::isEventQueue | ( | ) | [inline, virtual] |
tests for EventQueue interface being present.
This has to be overriden in classes that subclass EventQueue. See isEventGenerator for details.
- Returns:
- a pointer to the EventQueue interface, or NULL if it is not implemented.
Reimplemented in ot::EventQueueNode, ot::Transformation, and ot::RefNode.
Definition at line 433 of file Node.h.
Referenced by ot::Transformation::getEvent(), ot::Transformation::getEventNearTime(), ot::Transformation::getSize(), and ot::Transformation::isEventQueue().
| virtual int ot::Node::isNodePort | ( | ) | [inline, virtual] |
tests whether the node is a wrapper node.
This method is only there to distinguish wrapper nodes from other nodes.
- Returns:
- a pointer to the WrapperNode interface or NULL otherwise.
- Warning:
- Do not override this method ! This will result in your node being ignored by the parser.
Reimplemented in ot::Override, and ot::NodePort.
Definition at line 502 of file Node.h.
Referenced by countChildren(), countPorts(), getChild(), getPort(), ot::TimeGateNode::onEventGenerated(), ot::SelectionNode::onEventGenerated(), ot::MergeNode::onEventGenerated(), ot::GroupGateNode::onEventGenerated(), ot::DynamicTransformation::onEventGenerated(), ot::ButtonOpNode::onEventGenerated(), and updateObservers().
| virtual int ot::Node::isTimeDependend | ( | ) | [inline, virtual] |
tests for TimeDependend interface being present.
This has to be overriden in classes that subclass TimeDependend. See isEventGenerator for details.
- Returns:
- a pointer to the TimeDependend interface, or NULL if it is not implemented.
Reimplemented in ot::Transformation, and ot::RefNode.
Definition at line 478 of file Node.h.
Referenced by ot::Transformation::getEventAtTime(), and ot::Transformation::isTimeDependend().
this method notifies the object that a new event was generated.
It is called by an EventGenerator.
- Parameters:
-
event reference to the new event. Do not change the event values, make a copy and change that ! generator reference to the EventGenerator object that notified the EventObserver.
Reimplemented in ot::ButtonFilterNode, ot::ButtonHoldFilterNode, ot::ButtonOpNode, ot::CallbackNode, ot::ConfidenceFilterNode, ot::ConfidenceSelectNode, ot::ConsoleSink, ot::DynamicTransformation, ot::ElasticFilterNode, ot::EventQueueNode, ot::EventUtilityNode, ot::FileSink, ot::FilterNode, ot::GroupGateNode, ot::Override, ot::MergeNode, ot::PositionFilterNode, ot::RangeFilterNode, ot::SelectionNode, ot::ThresholdFilterNode, ot::TimeGateNode, ot::Transformation, ot::NodePort, ot::RefNode, ot::CORBASink, ot::DwarfSink, ot::NetworkSink, ot::TCPSink, ot::VRPNSink, ot::QtAppScreenPosSink, ot::QtMouseButtonSink, ot::QtMouseEventSinkBase, ot::QtMousePosSink, and ot::QtMouseWheelSink.
Definition at line 404 of file Node.h.
Referenced by updateObservers().
| void ot::Node::put | ( | const std::string & | key, | |
| const double * | value, | |||
| int | len | |||
| ) | [protected] |
sets an array of double values.
It is converted to a string where the values are separated by spaces and stored under the given key.
- Parameters:
-
key key string of the entry value pointer to the array of double values to store len the length of the array
Definition at line 678 of file Node.cxx.
References put().
| void ot::Node::put | ( | const std::string & | key, | |
| const float * | value, | |||
| int | len | |||
| ) | [protected] |
sets an array of float values.
It is converted to a string where the values are separated by spaces and stored under the given key.
- Parameters:
-
key key string of the entry value pointer to the array of floating point values to store len the length of the array
Definition at line 663 of file Node.cxx.
References put().
| void ot::Node::put | ( | const std::string & | key, | |
| const int * | value, | |||
| int | len | |||
| ) | [protected] |
sets an array of int values.
It is converted to a string where the values are separated by spaces and stored under the given key.
- Parameters:
-
key key string of the entry value pointer to the array of integer values to store len the length of the array
Definition at line 648 of file Node.cxx.
References put().
| void ot::Node::put | ( | const std::string & | key, | |
| const double | value | |||
| ) | [protected] |
| void ot::Node::put | ( | const std::string & | key, | |
| const float | value | |||
| ) | [protected] |
| void ot::Node::put | ( | const std::string & | key, | |
| const int | value | |||
| ) | [protected] |
| void ot::Node::put | ( | const std::string & | key, | |
| const std::string & | value | |||
| ) | [protected] |
stores a key value pair in the table, overwritting a possible prior value
- Parameters:
-
key the key to store it under value the value to store
Definition at line 583 of file Node.cxx.
References getContext(), ot::Context::getRootNamespace(), and parent.
Referenced by ot::Context::createNode(), and put().
| void ot::Node::remove | ( | const std::string & | key | ) | [protected] |
removes a key value pair from the table
- Parameters:
-
key the key to the pair
Definition at line 605 of file Node.cxx.
References getContext(), ot::Context::getRootNamespace(), and parent.
| Node::error ot::Node::removeChild | ( | Node & | child | ) |
removes a child from the direct children of a node.
This method will only work, if the passed node is actually a child of the node.
- Parameters:
-
child the child node to remove
- Returns:
- error code describing outcome of the operation
Definition at line 262 of file Node.cxx.
References NOT_FOUND, OK, and parent.
Referenced by removePort().
| Node::error ot::Node::removePort | ( | unsigned int | index | ) |
| Node::error ot::Node::removePort | ( | NodePort & | port | ) |
| Node::error ot::Node::removePort | ( | const std::string & | name | ) |
removes a child NodePort object.
Again similar to removeChild(), but for NodePorts. This method will only work, if a NodePort of the passed name is present on the node.
- Parameters:
-
name the name of the wrapper element
- Returns:
- error code describing outcome of the operation
Definition at line 481 of file Node.cxx.
References getPort(), and NOT_FOUND.
Referenced by removePort().
| void ot::Node::removeReference | ( | Node * | reference | ) | [protected] |
removes a reference from the list.
- Parameters:
-
reference the reference node to remove
Definition at line 146 of file Node.cxx.
References references.
| void ot::Node::setParent | ( | void * | parElement | ) | [protected, virtual] |
Definition at line 119 of file Node.cxx.
References parent, type, and ot::ud_node.
Referenced by ot::ConfigurationParser::buildConfigTree(), ot::ConfigurationParser::buildTree(), ot::Context::createNode(), and ot::ConfigurationParser::parseConfigurationFile().
| void ot::Node::updateObservers | ( | Event & | data | ) |
Updates the parent node and any reference nodes whenever a new event is generated by the Event interface.
This method should be used to propagate new events, as it implements correctly the event behaviour.
- Parameters:
-
data reference to the event value
Definition at line 524 of file Node.cxx.
References isEventGenerator(), isNodePort(), onEventGenerated(), parent, references, and ot::ud_node.
Referenced by ot::QtMouseEventSinkBase::forwardEvent(), ot::VRPNSink::onEventGenerated(), ot::Transformation::onEventGenerated(), ot::TimeGateNode::onEventGenerated(), ot::ThresholdFilterNode::onEventGenerated(), ot::SelectionNode::onEventGenerated(), ot::RangeFilterNode::onEventGenerated(), ot::PositionFilterNode::onEventGenerated(), ot::MergeNode::onEventGenerated(), ot::GroupGateNode::onEventGenerated(), ot::FilterNode::onEventGenerated(), ot::EventUtilityNode::onEventGenerated(), ot::EventQueueNode::onEventGenerated(), ot::ConfidenceSelectNode::onEventGenerated(), ot::ConfidenceFilterNode::onEventGenerated(), ot::ButtonOpNode::onEventGenerated(), ot::ButtonFilterNode::onEventGenerated(), ot::XSensSource::push(), ot::TestSource::push(), ot::ElasticFilterNode::push(), ot::CORBASource::push(), ot::ButtonHoldFilterNode::push(), ot::WacomGraphireModule::pushEvent(), and ot::FastTrakModule::pushEvent().
Friends And Related Function Documentation
friend class ConfigurationParser [friend] |
Member Data Documentation
std::string ot::Node::name [protected] |
the unique ID given in the XML configuration file.
Reimplemented in ot::CallbackNode, ot::EventUtilityNode, ot::DwarfSink, ot::VRPNSink, and ot::VRPNSource.
Definition at line 103 of file Node.h.
Referenced by ot::ConfigurationParser::buildTree().
void* ot::Node::parent [protected] |
Pointer to the parent XML element.
Definition at line 97 of file Node.h.
Referenced by addChild(), addPort(), countChildren(), countPorts(), ot::Context::createNode(), ot::Context::findNode(), get(), getChild(), getContext(), getParent(), getPort(), Node(), ot::Context::parseConfiguration(), put(), remove(), removeChild(), setParent(), updateObservers(), ot::XMLWriter::write(), and ~Node().
NodeVector ot::Node::references [protected] |
A Vector of pointers to reference nodes referencing this node.
Definition at line 100 of file Node.h.
Referenced by addReference(), removeReference(), updateObservers(), and ~Node().
std::string ot::Node::type [protected] |
the type of the node, equals the name of the configuration element
Reimplemented in ot::ConfidenceFilterNode, ot::ConfidenceSelectNode, ot::EventUtilityNode, ot::FilterNode, ot::VRPNSink, and ot::VRPNSource.
Definition at line 106 of file Node.h.
Referenced by ot::ARToolKitPlusModule::createNode(), and setParent().
The documentation for this class was generated from the following files: