ot::Node Class Reference
[Core Classes]

#include <Node.h>

Inheritance diagram for ot::Node:

Inheritance graph
[legend]
Collaboration diagram for ot::Node:

Collaboration graph
[legend]
List of all members.

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


Public Types

typedef Cptr< NodePtr
typedef std::vector< PtrNodeVector
enum  error {
  OK = 0, GRAPH_CONSTRAINT, READONLY, CONTEXT_ERROR,
  NOT_FOUND
}
 error type returned by some graph manipulation functions More...

Public Member Functions

 Node ()
virtual ~Node ()
const std::string & getType () const
const std::string & getName () const
void setName (const std::string &name_)
ContextgetContext () const
virtual int isNodePort ()
NodefindNode (const std::string &key, const std::string &val)
void addParent (Node *parent)
unsigned int countAllChildren ()
NodegetAnyChild (unsigned int index)
StringTablegetAttributes ()
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)
int get (const std::string &key, float *value, int len=1)
int get (const std::string &key, double *value, int len=1)
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)
Graph Navigation Interface
This set of methods allows to manipulate the data flow graph in a rather safe manner.

NodegetParent ()
NodegetParent (unsigned int index)
unsigned int countParents ()
unsigned int countChildren ()
NodegetChild (unsigned int index)
error addChild (Node &child)
error removeChild (Node &child)
unsigned int countPorts ()
NodePortgetPort (const std::string &name, unsigned int index=0)
NodePortgetPort (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 EventgetEvent (unsigned int index=0)
virtual EventgetEventNearTime (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 EventgetEventAtTime (double time)

Public Attributes

 OT_DECLARE_IREFCOUNTED

Protected Attributes

NodeVector parents
NodeVector children
StringTable attributes
std::string name
 the unique ID given in the XML configuration file.
std::string type
 the type of the node, equals the name of the configuration element

Friends

class Context


Member Typedef Documentation

typedef std::vector<Ptr> ot::Node::NodeVector
 

a Vector of Node pointers. Very useful to implement a simple container of Nodes such as a parent node, or to keep pointers to several nodes around.

typedef Cptr<Node> ot::Node::Ptr
 


Member Enumeration Documentation

enum ot::Node::error
 

error type returned by some graph manipulation functions

Enumerator:
OK  operation succeded
GRAPH_CONSTRAINT  operation failed because it is not allowed in the XML tree
READONLY  operation failed because the node is readonly
CONTEXT_ERROR  operation failed because the node belongs to another context
NOT_FOUND  operation failed because a node was not found


Constructor & Destructor Documentation

ot::Node::Node  ) 
 

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.

ot::Node::~Node  )  [virtual]
 

basic destructor.


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

void ot::Node::addParent Node parent  ) 
 

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

unsigned int ot::Node::countAllChildren  ) 
 

returns the total number of direct children. Without regards to whether they are nodeports or not. Meaning it counts ALL children

Returns:
unsigned number of children

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.

unsigned int ot::Node::countParents  ) 
 

returns the number of parents of this node

Returns:
unsigned number of parents

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

Node * ot::Node::findNode const std::string &  key,
const std::string &  val
 

Searches the tree rooted in this node for a node containing an attribute named key with the value val.

Returns:
a pointer to the node or null.

int ot::Node::get const std::string &  key,
double *  value,
int  len = 1
 

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

int ot::Node::get const std::string &  key,
float *  value,
int  len = 1
 

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

int ot::Node::get const std::string &  key,
int *  value,
int  len = 1
 

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

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

Node * ot::Node::getAnyChild unsigned int  index  ) 
 

returns a child at index, no matter whether it is a wrapper or not. Meaning it could return a nodeport.

Returns:
unsigned number of children

StringTable & ot::Node::getAttributes  ) 
 

Reimplemented in ot::ConfigNode.

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.

Context * ot::Node::getContext  )  const
 

returns a pointer to the Context this node lives in.

Returns:
pointer to Context

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, and ot::Transformation.

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.

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, and ot::Transformation.

const std::string& ot::Node::getName  )  const [inline]
 

returns the value of a unique ID set on the node. If no ID is set, this method returns an empty string

Returns:
string containing the unique ID

Node * ot::Node::getParent unsigned int  index  ) 
 

returns a parent indicated by the index.

Parameters:
index unsigned number =>0 and < countParents()
Returns:
pointer to the parent node or NULL if index is out of range.

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 node's parent will yield the true parent. The root node will return NULL, because it has no parent.

Returns:
pointer to parent 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.

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.

virtual unsigned int ot::Node::getSize  )  [inline, virtual]
 

returns the number of stored events.

Returns:
number of stored events.

Reimplemented in ot::EventQueueNode, and ot::Transformation.

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

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::CallforwardNode, ot::ConfidenceFilterNode, ot::ConfidenceSelectNode, ot::ConsoleSink, ot::ConsoleSource, ot::DESPFilterNode, ot::DifferenceNode, 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::TimestampGeneratorNode, ot::Transformation, ot::TestSource, ot::ARTDataTrackerSource, ot::DynaSightSource, ot::ECGSource, ot::EndoScoutSource, ot::FastTrakSource, ot::FlashpointSource, ot::FOBSource, ot::GENavSource, ot::GPSDirectionSource, ot::GPSGarminAltitude, ot::GPSGarminCompass, ot::GPSInfoSource, ot::GPSSource, ot::ICubeXSensor, ot::ICubeXSink, ot::ICubeXSource, ot::InterSenseSource, ot::MagicYSource, ot::MedScanSink, ot::MedScanSource, ot::MidiSink, ot::MidiSource, ot::MulticastInputSource, ot::NDISource, ot::OrientationSource, ot::ParButtonSource, QuatToMatrix, ot::RDSParallelRecon, ot::RDSRecon, ot::RDSSink, ot::RDSSource, ScanPlaneOrientationTransform, ot::SerButtonSource, ot::SpeechSource, ot::TerasonSink, ot::TerasonSource, ot::UltraTrakSource, ot::XSensSource, ot::ZTrackerTransform, ot::CORBASink, ot::CORBASource, ot::NetworkSink, ot::NetworkSource, ot::OldOTNetworkSource, ot::PhantomMiddlewareSink, ot::PhantomMiddlewareSource, ot::PushCons, ot::PushSupp, ot::SharedEngineNode, and ot::TCPSink.

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, and ot::Transformation.

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.

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.

virtual void ot::Node::onEventGenerated Event event,
Node generator
[inline, virtual]
 

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::DESPFilterNode, ot::DifferenceNode, 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::TimestampGeneratorNode, ot::Transformation, ot::NodePort, ot::CustomTransformation, ot::ICubeXSink, ot::MedScanSink, ot::MidiSink, QuatToMatrix, ot::RDSParallelRecon, ot::RDSRecon, ot::RDSSink, ot::RDSSource, ScanPlaneOrientationTransform, ot::TerasonSink, ot::ZTrackerTransform, ot::CORBASink, ot::CORBATransform, ot::NetworkSink, ot::PhantomMiddlewareSink, ot::PushSupp, ot::SharedEngineNode, and ot::TCPSink.

void ot::Node::put const std::string &  key,
const double *  value,
int  len
 

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

void ot::Node::put const std::string &  key,
const float *  value,
int  len
 

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

void ot::Node::put const std::string &  key,
const int *  value,
int  len
 

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

void ot::Node::put const std::string &  key,
const double  value
 

sets a double value, the value is converted to a string and stored under the given key.

Parameters:
key key string of the entry
value the double precision value to store

void ot::Node::put const std::string &  key,
const float  value
 

sets a float value, the value is converted to a string and stored under the given key.

Parameters:
key key string of the entry
value the floating point value to store

void ot::Node::put const std::string &  key,
const int  value
 

sets an int value, the value is converted to a string and stored under the given key.

Parameters:
key key string of the entry
value the integer value to store

void ot::Node::put const std::string &  key,
const std::string &  value
 

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

void ot::Node::remove const std::string &  key  ) 
 

removes a key value pair from the table

Parameters:
key the key to the pair

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

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

void ot::Node::setName const std::string &  name_  )  [inline]
 

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

Reimplemented in ot::CallforwardNode.


Friends And Related Function Documentation

friend class Context [friend]
 


Member Data Documentation

StringTable ot::Node::attributes [protected]
 

NodeVector ot::Node::children [protected]
 

std::string ot::Node::name [protected]
 

the unique ID given in the XML configuration file.

A Vector of pointers to reference nodes referencing this node. NodeVector references;

Reimplemented in ot::CallbackNode, ot::CallforwardNode, ot::EventUtilityNode, and ot::ICubeXSource.

ot::Node::OT_DECLARE_IREFCOUNTED
 

NodeVector ot::Node::parents [protected]
 

Pointer to the parent XML element.

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, and ot::FilterNode.


The documentation for this class was generated from the following files:
Generated on Wed Feb 28 15:29:07 2007 for NaviTrack by  doxygen 1.4.6