ot::Event Class Reference
[Core Classes]

#include <Event.h>

Collaboration diagram for ot::Event:

Collaboration graph
[legend]
List of all members.

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


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 getPrintOut (std::string &outstr) 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
 timestamp of the state in milliseconds since 1/1/1970

Static Public Attributes

static Event null
 typesafe null reference, to be used instead of a NULL pointer


Constructor & Destructor Documentation

ot::Event::Event  ) 
 

Standard constructor. The event gets a current 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

ot::Event::~Event  ) 
 

Destructor, deleting all attributes held by the event.


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

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

void ot::Event::clearAttributes  ) 
 

Deletes all attributes held by the 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

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

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

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

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

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

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

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

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

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

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

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

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

unsigned short & ot::Event::getButton  ) 
 

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

Returns:
button attribute

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

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

Returns:
confidence attribute

float & ot::Event::getConfidence  ) 
 

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

Returns:
confidence attribute

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

std::vector< float > & ot::Event::getOrientation  ) 
 

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

Returns:
orientation attribute

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

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

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

Returns:
position attribute

void ot::Event::getPrintOut std::string &  outstr  )  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

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

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

Return the number of attributes held by the event.

Returns:
number of attributes

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

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

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

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.

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'.

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

Converts Event into a CORBA sequence of string-any structs, which is the CORBA definition of the OpenTracker event type

Returns:
the CORBA Event sequence

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

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

Serializes the event's data into a string.

Returns:
a string encoding the event's data

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

Serializes the event's data into an output stream.

Parameters:
out the output stream

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

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

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

Sets the value of the attribute 'button'.

Parameters:
value the new button value

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

Sets the value of the attribute 'confidence'.

Parameters:
value the new confidence value

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

Sets the value of the attribute 'orientation'.

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

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)

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

Sets the value of the attribute 'position'.

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

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)

void ot::Event::timeStamp  ) 
 

Updates the event's timestamp to the current time.


Member Data Documentation

Event ot::Event::null [static]
 

typesafe null reference, to be used instead of a NULL pointer

double ot::Event::time
 

timestamp of the state in milliseconds since 1/1/1970


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