OpenTracker

An Open Architecture for Reconfigurable Tracking based on XML | Contact

ot::OTQt Class Reference
[OTQt Classes]

OTQt main class More...

#include <OTQt.h>

Inheritance diagram for ot::OTQt:

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

Collaboration graph
[legend]
List of all members.

Public Member Functions

virtual ~OTQt ()
void init (std::string &cfg_filename)
bool isInitialized () const
void startTimer (unsigned int timeout=DEFAULT_TIMER_TIMEOUT_MSEC)
bool isTimerActive () const
void stopTimer ()
bool enableMouseEvents (bool enable)

Static Public Member Functions

static OTQtgetInstance ()
static bool triggerMEM (std::string cfg_filename)

Static Public Attributes

static int const DEFAULT_TIMER_TIMEOUT_MSEC = 20

Protected Slots

void driveOT ()

Protected Member Functions

 OTQt ()
QtMouseEventModulegetMEM ()
QtMouseEventCalibModulegetMECM ()

Private Member Functions

 OTQt (OTQt const &ref)
OTQt operator= (OTQt const &ref)

Private Attributes

bool is_initialized_
Context context_
QtMouseEventModuleme_mod_
QtMouseEventCalibModulemec_mod_
std::string cfg_filename_
QMutexmutex_
QTimertimer_
unsigned int cycle_counter_

Static Private Attributes

static OTQtthe_instance_ = NULL

Detailed Description

OTQt main class

Provides the public interface towards target Qt applications and offers some protected members to deriving classes. Internally the class is responsible for initializing the OpenTracker context and adding the MEM and MECM to a context factory.

It provides the necessary interface to exectute both OTQt modes. Calibration and operation mode differ in the way how the OpenTracker data flow is driven. Basically OTQt drives the OpenTracker data flow in cycles. Performing an OpenTracker cycle means one execution of the data flow graph: source nodes import adjacent tracking events from "outside", filter nodes queue events or perform their operations and forward the modified events according to the OpenTracker push pattern until the events arrive at the OTQt sinks nodes. The method driveOT() abstracts the procedure of such an OpenTracker cycle. The two modes use this method differently. In operation mode, driveOT() method is called periodically by a timer thread, a tradeoff between in-time delivery (accuracy) of mouse events and processing overhead of OTQt. For the calibration procedure, executed in a dedicated command line tool as separate process, the processing overhead restrictions do not apply. Therefore the driveOT() method is called from within the calibration procedure code directly often nested in busy-waiting while-loops.

The OTQt class provides a singleton pattern to the target Qt application. With the getInstance() method the singleton instance can be retrieved from any point in Qt code allowing the access of the OTQt class public interface. The triggerMEM() method abstracts the initialization and startup of OTQt reducing the effort of implementation within a Qt application to one line of code.

Definition at line 107 of file OTQt.h.


Constructor & Destructor Documentation

ot::OTQt::~OTQt (  )  [virtual]

Destructor.

Definition at line 71 of file OTQt.cxx.

References me_mod_, mec_mod_, mutex_, and timer_.

ot::OTQt::OTQt (  )  [protected]

Initializes member variables.

Does NOT initialize the OpenTracker context, thus returns an object in not intialized state.

Definition at line 57 of file OTQt.cxx.

Referenced by getInstance().

ot::OTQt::OTQt ( OTQt const &  ref  )  [private]


Member Function Documentation

void ot::OTQt::driveOT (  )  [protected, slot]

Performs one OpenTracker cycle.

Performing an OpenTracker cycle means one execution of the data flow graph: source nodes import adjacent tracking events from "outside", filter nodes queue events or perform their operations and forward the modified events according to the OpenTracker push pattern until the events arrive at the OTQt sinks nodes.

The method body is treated as critical section secured with a mutex lock. A thread calling the method trying to acquire the locked mutex returns immediately, thus the method is non-blocking. Otherwise the mutex is acquired at the beginning and released at the end of the critical section implementing the OpenTracker cycle.

Disables the pending event flags set in the previous OT cycle. All sinks in both modules are reseted. The reset is done at the beginning of the new cycle BEFORE the sinks and modules are processed. Thus, when this method returns, the pending event flags set in the current cycle are still enabled and accessible.

Definition at line 131 of file OTQt.cxx.

References ot::Context::close(), context_, QTime::currentTime(), cycle_counter_, me_mod_, mec_mod_, QTime::msec(), mutex_, OTQT_DEBUG(), OTQT_ERROR(), ot::Context::pullEvents(), ot::Context::pushEvents(), ot::QtMouseEventModuleBase::resetPendingEventBitAllSinks(), ot::Context::stop(), stopTimer(), QMutex::tryLock(), and QMutex::unlock().

Referenced by init(), ot::OTQtMEMCalibProc::trackASCorner(), ot::OTQtMEMCalibProc::trackASCornerMain(), ot::OTQtMEMCalibProc::trackASPos(), ot::OTQtMEMCalibProc::trackMBDButtonOne(), and ot::OTQtMEMCalibProc::trackMPD().

bool ot::OTQt::enableMouseEvents ( bool  enable  )  [inline]

Enables or disables the distribution of mouse events to the target Qt application in the MEM depending on the given boolean argument.

Returns the current state of the mouse event distribution, thus returns true if mouse event distribution is enabled and false if disabled.

Parameters:
enable true means enable, false means disable mouse event distribution
Returns:
current state of MEM mouse event distribution, true if enabled, false if disabled

Definition at line 207 of file OTQt.h.

Referenced by triggerMEM().

OTQt & ot::OTQt::getInstance (  )  [static]

Returns the OTQt singleton instance.

Creates the singleton instance if it currently does not exist.

Returns:
singleton instance

Definition at line 82 of file OTQt.cxx.

References OTQt(), and the_instance_.

Referenced by triggerMEM().

QtMouseEventCalibModule& ot::OTQt::getMECM (  )  [inline, protected]

QtMouseEventModule& ot::OTQt::getMEM (  )  [inline, protected]

Returns the MEM object added to the OpenTracker context.

Returns:
MEM object

Definition at line 215 of file OTQt.h.

void ot::OTQt::init ( std::string &  cfg_filename  ) 

Creates and initializes the OpenTracker context.

Adds the MEM and MECM to a context factory. Parses the given configuration file. During parsing the node graph is created. Switches state of object to initialized.

Parameters:
cfg_filename XML configuration filename

Definition at line 91 of file OTQt.cxx.

References ot::Context::addFactory(), ot::Context::addModule(), cfg_filename_, QObject::connect(), context_, driveOT(), ot::initializeContext(), is_initialized_, me_mod_, mec_mod_, ot::Context::parseConfiguration(), ot::Context::start(), and timer_.

Referenced by ot::OTQtMEMCalibProc::exec(), and triggerMEM().

bool ot::OTQt::isInitialized (  )  const [inline]

Returns true if object state is initialized.

Otherwise returns false.

Returns:
true if object state is initialized.

Definition at line 173 of file OTQt.h.

bool ot::OTQt::isTimerActive (  )  const [inline]

Returns true if the timer thread is currently running.

Returns:
true if timer thread currently running

Definition at line 189 of file OTQt.h.

OTQt ot::OTQt::operator= ( OTQt const &  ref  )  [private]

void ot::OTQt::startTimer ( unsigned int  timeout = DEFAULT_TIMER_TIMEOUT_MSEC  ) 

Starts the operation mode timer thread with given timeout.

If the timer argument is omitted, the default timeout is used. Does nothing if the timer thread is already running.

Parameters:
timeout timer thread timeout in milliseconds

Definition at line 117 of file OTQt.cxx.

References QTimer::isActive(), QTimer::start(), QTimer::stop(), and timer_.

Referenced by triggerMEM().

void ot::OTQt::stopTimer (  ) 

Stops the timer thread if it is currently running.

Otherwise does nothing.

Definition at line 125 of file OTQt.cxx.

References QTimer::isActive(), QTimer::stop(), and timer_.

Referenced by driveOT().

bool ot::OTQt::triggerMEM ( std::string  cfg_filename  )  [static]

Initializes the OTQt MEM module.

Designed to be implemented in target Qt applications. Initializes the OpenTracker context, adds MEM to the context factory, parses the given configuration file, enables the mouse event generation and finally starts the timer thread with the default timeout. Returns true if OTQt startup was successful, otherwise returns false (eg in case of an exception).

Parameters:
cfg_filename XML configuration filename
Returns:
true if OTQt startup successful

Definition at line 190 of file OTQt.cxx.

References enableMouseEvents(), getInstance(), init(), OTQT_ERROR(), and startTimer().


Member Data Documentation

std::string ot::OTQt::cfg_filename_ [private]

name of XML configuration file

Definition at line 253 of file OTQt.h.

Referenced by init().

OpenTracker context object.

Definition at line 247 of file OTQt.h.

Referenced by driveOT(), and init().

unsigned int ot::OTQt::cycle_counter_ [private]

Definition at line 260 of file OTQt.h.

Referenced by driveOT().

int const ot::OTQt::DEFAULT_TIMER_TIMEOUT_MSEC = 20 [static]

default operation mode timer thread timeout in milliseconds

Definition at line 114 of file OTQt.h.

bool ot::OTQt::is_initialized_ [private]

OpenTracker context initialzed state varible (true if initialized, false if not initialized).

Definition at line 245 of file OTQt.h.

Referenced by init().

MEM object added to OpenTracker context.

Definition at line 249 of file OTQt.h.

Referenced by driveOT(), init(), and ~OTQt().

MECM object added to OpenTracker context.

Definition at line 251 of file OTQt.h.

Referenced by driveOT(), init(), and ~OTQt().

mutex lock employed in the driveOT() method

Definition at line 255 of file OTQt.h.

Referenced by driveOT(), and ~OTQt().

OTQt * ot::OTQt::the_instance_ = NULL [static, private]

the singleton instance

Definition at line 138 of file OTQt.h.

Referenced by getInstance().

operation mode timer thread

Definition at line 257 of file OTQt.h.

Referenced by init(), startTimer(), stopTimer(), and ~OTQt().


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

copyright (c) 2006 Graz University of Technology