OpenTracker

An Open Architecture for Reconfigurable Tracking based on XML | Contact

ot::Event Class Reference
[Core Classes]

The Event, which is passing through the configuration tree and is holding all multi-modal attributes. More...

#include <Event.h>

Collaboration diagram for ot::Event:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 Event ()
 Event (const Event &rv)
 ~Event ()
Eventoperator= (const Event &rv)
bool hasAttribute (const std::string &name) const
bool delAttribute (const std::string &name)
bool renAttribute (const std::string &oldName, const std::string &newName)
void copyAllButStdAttr (const Event &rv)
void clearAttributes ()
void printout () const
const std::string getPrintOut () const
void timeStamp ()
void serialize (std::ostream &out) const
const std::string serialize () const
std::istream & deserialize (std::istream &in)
void deserialize (std::string &str)
int getSize () const
const std::type_info & getAttributeType (const std::string &name) const throw (std::invalid_argument)
const std::string & getAttributeTypeName (const std::string &name) const throw (std::invalid_argument)
const std::string & getAttributeName (const int index) const throw (std::invalid_argument)
int getAttributeIndex (const std::string &name) const throw (std::invalid_argument)
template<typename T>
T & getAttribute (const T *dummy, const std::string &name)
template<typename T>
const T & getAttribute (const T *dummy, const std::string &name) const throw (std::invalid_argument)
template<typename T>
T & getAttribute (const std::string &name, const T &defValue)
template<typename T>
bool addAttribute (const std::string &name, const T &value)
template<typename T>
bool setAttribute (const std::string &name, const T &value)
Convenience Functions to Access Former Standard Attributes
This set of methods does not add any functionality, it just provides an easy and convenience way to access former standard attributes (position, orientation, button, and confidence). These functions can also be used for easily porting applications using the fixed data structure of OpenTracker 1.1 states to new multi-modal events.

All get-methods may throw std::invalid_argument exceptions if attributes with the same name but of another type exist!

std::vector< float > & getPosition ()
const std::vector< float > & getPosition () const
std::vector< float > & getOrientation ()
const std::vector< float > & getOrientation () const
float & getConfidence ()
const float & getConfidence () const
unsigned short & getButton ()
const unsigned short & getButton () const
void setPosition (const std::vector< float > &value)
void setPosition (const float *value)
void setOrientation (const std::vector< float > &value)
void setOrientation (const float *value)
void setConfidence (const float &value)
void setButton (const unsigned short &value)
Non Template Interface
This set of methods allows access of attributes if the attribute's type is not known yet during compile time. Therefore, type and value of attributes are encoded in strings.

bool addAttribute (const std::string &type, const std::string &name, const std::string &value)
bool setAttribute (const std::string &type, const std::string &name, const std::string &value)
const std::string getAttributeValueString (const std::string &name) const throw (std::invalid_argument)

Static Public Member Functions

static void registerAllKnownTypes ()
static bool knowsType (const std::string typeName)
template<typename T>
static void registerGenericTypeName (const T *dummy, const std::string &genericTypeName)

Public Attributes

double time

Static Public Attributes

static Event null

Private Attributes

AttributeMap attributes

Detailed Description

The Event, which is passing through the configuration tree and is holding all multi-modal attributes.

This class implements all kinds of functions necessary to deal with events and their attributes. Attributes can be added, read, changed, or deleted. This class encapsulates access to all attributes. It is therefore the only interface to deal with the values of the attributes.

This class replaces the obsolete State class, which was used in OpenTracker 1.1.

Author:
Jochen von Spiczak

Definition at line 125 of file Event.h.


Constructor & Destructor Documentation

ot::Event::Event (  ) 

Standard constructor.

The event gets a current timestamp.

Definition at line 59 of file Event.cxx.

References timeStamp().

ot::Event::Event ( const Event rv  ) 

Copy constructor.

Copies all attributes of another event into the new one.

Parameters:
rv the right-value, which is the event to copy from

Definition at line 65 of file Event.cxx.

ot::Event::~Event (  ) 

Destructor, deleting all attributes held by the event.

Definition at line 71 of file Event.cxx.

References clearAttributes().


Member Function Documentation

template<typename T>
bool ot::Event::addAttribute ( const std::string &  name,
const T &  value 
) [inline]

Adds a new attribute.

Throws an exception if type is not known.

Parameters:
name the name of the new attribute
value the value of the new attribute
Returns:
whether creation of attribute was successful

Definition at line 472 of file Event.h.

References ot::EventAttributeBase::create().

bool ot::Event::addAttribute ( const std::string &  type,
const std::string &  name,
const std::string &  value 
)

Adds a new attribute.

The attribute's type and value are encoded in strings. Throws an exception if type is not known.

Parameters:
type the generic type name of the attribute
name the name of the attribute
value the value of the new attribute
Returns:
whether creation of the new attribute was successful

Definition at line 305 of file Event.cxx.

References attributes, ot::EventAttributeBase::create(), and hasAttribute().

Referenced by ot::GPSSource::newData(), and ot::EventUtilityNode::onEventGenerated().

void ot::Event::clearAttributes (  ) 

Deletes all attributes held by the event.

Definition at line 352 of file Event.cxx.

References attributes.

Referenced by ot::UbisenseSource::calcEvent(), deserialize(), operator=(), and ~Event().

void ot::Event::copyAllButStdAttr ( const Event rv  ) 

Copies all but standard attributes, which were used in OT11.

Standard attributes are position, orientation, button, and confidence.

Parameters:
rv the right-value, which is the event to copy from

Definition at line 96 of file Event.cxx.

References attributes, ot::EventAttributeBase::create(), delAttribute(), and ot::EventAttributeBase::getGenericTypeName().

Referenced by ot::VirtualTransformation::transformEvent(), ot::StaticTransformation::transformEvent(), ot::MatrixTransformation::transformEvent(), ot::InvertTransformation::transformEvent(), ot::GKTransformNode::transformEvent(), and ot::EllipsoidTransformNode::transformEvent().

bool ot::Event::delAttribute ( const std::string &  name  ) 

Deletes an attribute.

Parameters:
name name of the attribute that should be deleted
Returns:
whether deletion was successful

Definition at line 337 of file Event.cxx.

References attributes.

Referenced by copyAllButStdAttr(), ot::MergeNode::onEventGenerated(), and ot::EventUtilityNode::onEventGenerated().

void ot::Event::deserialize ( std::string &  str  ) 

Deserializes an event from a string.

Naturally, the data in the string must be a correctly serialized event.

Parameters:
str the string encoding the event

Definition at line 231 of file Event.cxx.

std::istream & ot::Event::deserialize ( std::istream &  in  ) 

Deserializes an event from an input stream.

Naturally, the data coming from the input stream must be a correctly serialized event.

Parameters:
in the input stream
Returns:
the input stream

Definition at line 238 of file Event.cxx.

References attributes, clearAttributes(), ot::EventAttributeBase::create(), hasAttribute(), and time.

Referenced by ot::operator>>().

template<typename T>
T& ot::Event::getAttribute ( const std::string &  name,
const T &  defValue 
) [inline]

Returns a reference to the value of the attribute called name.

If no such attribute is present, a new attribute is created according to defValue. Throws an exception if the type is not known or if an attribute with the same name but of a different type is present.

Parameters:
dummy a dummy pointer to deduce the template parameter (use like (int*)NULL, just added for VC6 support)
name the name of the attribute
Returns:
reference to the attribute's value

Definition at line 453 of file Event.h.

template<typename T>
const T& ot::Event::getAttribute ( const T *  dummy,
const std::string &  name 
) const throw (std::invalid_argument) [inline]

Returns a reference to the value of the attribute called name.

Throws an exception if such attribute is not present.

Parameters:
dummy a dummy pointer to deduce the template parameter (use like (int*)NULL, just added for VC6 support)
name the name of the attribute
Returns:
reference to the attribute's value

Definition at line 440 of file Event.h.

template<typename T>
T& ot::Event::getAttribute ( const T *  dummy,
const std::string &  name 
) [inline]

Returns a reference to the value of the attribute called name.

Throws an exception if such attribute is not present.

Parameters:
dummy a dummy pointer to deduce the template parameter (use like (int*)NULL, just added for VC6 support)
name the name of the attribute
Returns:
reference to the attribute's value

Definition at line 412 of file Event.h.

References ot::EventAttribute< T >::get().

Referenced by getButton(), getConfidence(), getOrientation(), and getPosition().

int ot::Event::getAttributeIndex ( const std::string &  name  )  const throw (std::invalid_argument)

Returns the index of an attribute by name.

An exception is thrown if the name is not valid.

Parameters:
name the name of the attribute
Returns:
the index of the attribute

Definition at line 132 of file Event.cxx.

const std::string & ot::Event::getAttributeName ( const int  index  )  const throw (std::invalid_argument)

Returns the name of an attribute by index.

An exception is thrown if the index is not valid.

Parameters:
index the index of the attribute
Returns:
the name of the attribute

Definition at line 117 of file Event.cxx.

const std::type_info & ot::Event::getAttributeType ( const std::string &  name  )  const throw (std::invalid_argument)

Returns the RTTI type information of an attribute's value.

An exception is thrown if the name is not valid.

Parameters:
name the name of the attribute
Returns:
RTTI type information

Definition at line 146 of file Event.cxx.

References ot::EventAttributeBase::getType().

const std::string & ot::Event::getAttributeTypeName ( const std::string &  name  )  const throw (std::invalid_argument)

Return the generic type name of an attribute's value.

An exception is thrown if the name is not valid.

Parameters:
name the name of the attribute
Returns:
the generic type name

Definition at line 158 of file Event.cxx.

References ot::EventAttributeBase::getGenericTypeName().

Referenced by ot::MergeNode::onEventGenerated().

const std::string ot::Event::getAttributeValueString ( const std::string &  name  )  const throw (std::invalid_argument)

Returns the value of an attribute encoded in a string.

Parameters:
name the name of the attribute
Returns:
the attribute's value encoded in a string

Definition at line 170 of file Event.cxx.

Referenced by ot::MergeNode::onEventGenerated().

const unsigned short& ot::Event::getButton (  )  const [inline]

Returns the value of the attribute 'button', which is a single unsigned short value.

Returns:
button attribute

Definition at line 302 of file Event.h.

const float& ot::Event::getConfidence (  )  const [inline]

Returns the value of the attribute 'confidence', which is a single float value.

Returns:
confidence attribute

Definition at line 292 of file Event.h.

const std::vector<float>& ot::Event::getOrientation (  )  const [inline]

Returns the value of the attribute 'orientation', which is a float vector of size 4.

Returns:
orientation attribute

Definition at line 282 of file Event.h.

const std::vector<float>& ot::Event::getPosition (  )  const [inline]

Returns the value of the attribute 'position', which is a float vector of size 3.

Returns:
position attribute

Definition at line 272 of file Event.h.

std::vector< float > & ot::Event::getPosition (  ) 

Returns the value of the attribute 'position', which is a float vector of size 3.

Returns:
position attribute

Definition at line 184 of file Event.cxx.

References getAttribute().

Referenced by ot::UbisenseSource::calcEvent(), ot::QtAppScreen::convert(), ot::Bird::convert(), ot::CORBAUtils::convertToCORBAEvent(), ot::TestModule::createNode(), ot::OTQtMEMCalibProc::exec(), ot::QtMouseEventSinkBase::isInsidePosThreshSphere(), ot::MagicY::MagicY(), ot::GPSInfoSource::newData(), ot::GPSGarminAltitude::newData(), ot::GPSDirectionSource::newData(), ot::VRPNSink::onEventGenerated(), ot::ThresholdFilterNode::onEventGenerated(), ot::RangeFilterNode::onEventGenerated(), ot::QtMousePosSink::onEventGenerated(), ot::QtAppScreenPosSink::onEventGenerated(), ot::PositionFilterNode::onEventGenerated(), ot::FilterNode::onEventGenerated(), ot::DynamicTransformation::onEventGenerated(), ot::JoystickModule::pollJoysticks(), ot::SpaceMouseModule::processMessages(), ot::TCPModule::pullEvent(), ot::TestSource::push(), ot::ElasticFilterNode::push(), ot::WacomGraphireModule::pushEvent(), ot::QtAppScreen::QtAppScreen(), ot::File::read(), ot::DynaSightModule::run(), ot::OTQtMEMCalibProc::trackASCorner(), ot::OTQtMEMCalibProc::trackASCornerMain(), ot::VirtualTransformation::transformEvent(), ot::StaticTransformation::transformEvent(), ot::MatrixTransformation::transformEvent(), ot::InvertTransformation::transformEvent(), ot::GKTransformNode::transformEvent(), ot::EllipsoidTransformNode::transformEvent(), ot::OTQtMath::transformVectorFromCSToCS(), ot::ARToolKitPlusModule::updateEvent(), ot::QtAppScreen::updateMPD(), and ot::File::write().

const std::string ot::Event::getPrintOut (  )  const

Returns a string that can be used to print out all data held by the event.

For a more compact layout of the same data use the serialize functions or streaming operators.

Returns:
string holding the event's data

Definition at line 368 of file Event.cxx.

References attributes, and time.

Referenced by printout().

int ot::Event::getSize (  )  const [inline]

Return the number of attributes held by the event.

Returns:
number of attributes

Definition at line 219 of file Event.h.

bool ot::Event::hasAttribute ( const std::string &  name  )  const

Checks for the existence of an attribute by its name.

Parameters:
name the name of the attribute to check for
Returns:
whether the event has an attribute called name

Definition at line 397 of file Event.cxx.

References attributes.

Referenced by addAttribute(), deserialize(), ot::EventUtilityNode::onEventGenerated(), and setAttribute().

bool ot::Event::knowsType ( const std::string  typeName  )  [static]

Checks whether a generic type name is known by the system.

Parameters:
typeName the generic type name to be checked
Returns:
whether the type name is known by the system

Definition at line 403 of file Event.cxx.

References ot::Translator::knowsType(), and ot::EventAttributeBase::translator.

Event & ot::Event::operator= ( const Event rv  ) 

Assignment operator.

Copies all attributes of another event into this one.

Parameters:
rv the right-value, which is the event to copy from

Definition at line 77 of file Event.cxx.

References attributes, clearAttributes(), ot::EventAttributeBase::create(), and time.

void ot::Event::printout (  )  const

Prints out all data held by the event.

Uses the standard output device. This function should be used mainly for debugging purposes.

Definition at line 360 of file Event.cxx.

References getPrintOut(), and LOG_ACE_INFO().

void ot::Event::registerAllKnownTypes (  )  [static]

Registers all types that can be used within the OpenTracker library.

Every type is registered with a generic typename, which is arbitrary but must be unique. In this function, the generic type names are matched to the according creator functions, which are created automatically.

If a new type needs to be added to the library permanently, a new line should be added to this function. Every registered type must provide a standard constructor and streaming operators, which can be defined in 'core/iostream_ext.h'.

Definition at line 409 of file Event.cxx.

References registerGenericTypeName().

Referenced by ot::initializeContext().

template<typename T>
static void ot::Event::registerGenericTypeName ( const T *  dummy,
const std::string &  genericTypeName 
) [inline, static]

Registers a new generic type name.

Type names are arbitrary but must be unique. In this function, the generic type name is matched to the according creator function, which is created automatically.

Every registered type must provide a standard constructor and streaming operators, which can be defined in 'core/iostream_ext.h'.

Parameters:
dummy a dummy pointer to deduce the template parameter (use like (int*)NULL, just added for VC6 support)
genericTypeName the generic type name to be registered (must be unique!)

Definition at line 400 of file Event.h.

References ot::EventAttributeBase::registerType().

Referenced by registerAllKnownTypes().

bool ot::Event::renAttribute ( const std::string &  oldName,
const std::string &  newName 
)

Renames an attribute.

Parameters:
oldName the name of the attribute that should be renamed
newName the new name
Returns:
whether renaming was successful

Definition at line 381 of file Event.cxx.

References attributes.

Referenced by ot::EventUtilityNode::onEventGenerated().

const std::string ot::Event::serialize (  )  const

Serializes the event's data into a string.

Returns:
a string encoding the event's data

Definition at line 224 of file Event.cxx.

void ot::Event::serialize ( std::ostream &  out  )  const

Serializes the event's data into an output stream.

Parameters:
out the output stream

Definition at line 210 of file Event.cxx.

References attributes, and time.

Referenced by ot::operator<<().

template<typename T>
bool ot::Event::setAttribute ( const std::string &  name,
const T &  value 
) [inline]

Sets the value of an attribute.

If currently no attribute called name is present, a new attribute is created accordingly. Throws an exception if type is not known.

Parameters:
name the name of the attribute
value the new value of the attribute
Returns:
whether setting or creation of the attribute was successful

Definition at line 491 of file Event.h.

References ot::EventAttributeBase::create(), and ot::EventAttribute< T >::set().

bool ot::Event::setAttribute ( const std::string &  type,
const std::string &  name,
const std::string &  value 
)

Sets the value of an attribute.

The type and the value of the attribute are encoded in strings. If currently no attribute called name is present, a new attribute is created accordingly. Throws an exception if type is not known.

Parameters:
type the generic type name of the attribute
name the name of the attribute
value the value encoded in a string
Returns:
whether setting or creation of the attribute was successful

Definition at line 325 of file Event.cxx.

References attributes, ot::EventAttributeBase::create(), and hasAttribute().

Referenced by ot::GPSSource::newData(), ot::MergeNode::onEventGenerated(), and ot::TestSource::push().

void ot::Event::setButton ( const unsigned short &  value  )  [inline]

Sets the value of the attribute 'button'.

Parameters:
value the new button value

Definition at line 332 of file Event.h.

Referenced by ot::CORBAUtils::convertFromCORBAEvent(), and ot::TestSource::push().

void ot::Event::setConfidence ( const float &  value  )  [inline]

Sets the value of the attribute 'confidence'.

Parameters:
value the new confidence value

Definition at line 327 of file Event.h.

Referenced by ot::TestSource::push().

void ot::Event::setOrientation ( const float *  value  )  [inline]

Sets the value of the attribute 'orientation'.

Parameters:
value the new orientation value (size 4 expected)

Definition at line 322 of file Event.h.

References ot::copyA2V().

void ot::Event::setOrientation ( const std::vector< float > &  value  )  [inline]

Sets the value of the attribute 'orientation'.

Parameters:
value the new orientation value (size 4 expected)

Definition at line 317 of file Event.h.

Referenced by ot::CORBAUtils::convertFromCORBAEvent().

void ot::Event::setPosition ( const float *  value  )  [inline]

Sets the value of the attribute 'position'.

Parameters:
value the new position value (size 3 expected)

Definition at line 312 of file Event.h.

References ot::copyA2V().

void ot::Event::setPosition ( const std::vector< float > &  value  )  [inline]

Sets the value of the attribute 'position'.

Parameters:
value the new position value (size 3 expected)

Definition at line 307 of file Event.h.

Referenced by ot::CORBAUtils::convertFromCORBAEvent(), and ot::GPSSource::newData().


Member Data Documentation


The documentation for this class was generated from the following files:

copyright (c) 2006 Graz University of Technology