gadget::GestureProxy Class Reference

Proxy to Gesture object. More...

#include <gadget/Type/GestureProxy.h>

Inheritance diagram for gadget::GestureProxy:

Inheritance graph
[legend]
Collaboration diagram for gadget::GestureProxy:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 GestureProxy ()
 Constructs the proxy to point to the given gesture device.
virtual ~GestureProxy ()
int getGesture ()
 Gets the current gesture.
int getGestureIndex (std::string name)
 Returns the identifier of the string gesture.
std::string getGestureString (int gestureId=-1)
 Gets a gesture name.
vpr::Interval getTimeStamp () const
 Returns time of last update.
GesturegetGesturePtr ()
 Returns a pointer to the device held by this proxy.
bool config (jccl::ConfigElementPtr element)
 Configures the proxy.
virtual InputgetProxiedInputDevice ()
 Returns a pointer to the base class of the devices being proxied.

Static Public Member Functions

static std::string getElementType ()
 Returns the string rep of the element type used to config this device.

Detailed Description

Proxy to Gesture object.

A proxy is used by the user to actually acces the gesture data. The proxy allows the user to query the current gesture information. Clients call the get* routines to get the current gesture (id or string) Once the client has the current gesture, they should test it against the gestures they want to respond to.

See also:
gadget::Gesture

Definition at line 64 of file GestureProxy.h.


Constructor & Destructor Documentation

gadget::GestureProxy::GestureProxy (  )  [inline]

Constructs the proxy to point to the given gesture device.

Definition at line 68 of file GestureProxy.h.

00069    { ;}

virtual gadget::GestureProxy::~GestureProxy (  )  [inline, virtual]

Definition at line 71 of file GestureProxy.h.

00072    {}


Member Function Documentation

int gadget::GestureProxy::getGesture (  )  [inline]

Gets the current gesture.

Returns:
id of current gesture.

Definition at line 78 of file GestureProxy.h.

00079    {
00080       const int defaultGesture(-1);
00081 
00082       if(isStupefied())
00083          return defaultGesture;
00084       else
00085          return mTypedDevice->getGesture();
00086    }

int gadget::GestureProxy::getGestureIndex ( std::string  name  )  [inline]

Returns the identifier of the string gesture.

Parameters:
name The string name of a gesture.
Returns:
-1 if not found

Definition at line 93 of file GestureProxy.h.

00094    {
00095       const int defaultGestureIndex(-1);
00096       if(isStupefied())
00097          return defaultGestureIndex;
00098       else
00099          return mTypedDevice->getGestureIndex(name);
00100    }

std::string gadget::GestureProxy::getGestureString ( int  gestureId = -1  )  [inline]

Gets a gesture name.

Returns:
Name of gesture with the given id (gestureId).
Note:
if gestureId = -1, returns name of current gesture.

Definition at line 107 of file GestureProxy.h.

00108    {
00109       if(isStupefied())
00110          return std::string("");
00111       else
00112          return mTypedDevice->getGestureString(gestureId);
00113    }

vpr::Interval gadget::GestureProxy::getTimeStamp (  )  const [inline, virtual]

Returns time of last update.

Implements gadget::Proxy.

Definition at line 116 of file GestureProxy.h.

00117    {
00118       // XXX: Broken for now, this is a case similar to the KeyboardMouse type in that
00119       //      it does not point to one data element like digital, analog, and position.
00120       return vpr::Interval();
00121    }

Gesture* gadget::GestureProxy::getGesturePtr (  )  [inline]

Returns a pointer to the device held by this proxy.

Definition at line 124 of file GestureProxy.h.

00125    {
00126       if(isStupefied())
00127          return NULL;
00128       else
00129          return mTypedDevice;
00130    }

std::string gadget::GestureProxy::getElementType (  )  [static]

Returns the string rep of the element type used to config this device.

Used by the Input Manager to find elements that construct devices.

Reimplemented from gadget::Proxy.

Definition at line 42 of file GestureProxy.cpp.

Referenced by gadget::ProxyDepChecker::canHandle(), and config().

00043 {
00044    return "gesture_proxy";
00045 }

bool gadget::GestureProxy::config ( jccl::ConfigElementPtr  element  )  [virtual]

Configures the proxy.

Postcondition:
Proxy is configured (it is not registered yet though).
Returns:
success.

Reimplemented from gadget::Proxy.

Definition at line 47 of file GestureProxy.cpp.

References gadget::Proxy::config(), gadgetDBG_INPUT_MGR(), getElementType(), gadget::TypedProxy< DEV_TYPE >::mDeviceName, and gadget::TypedProxy< DEV_TYPE >::refresh().

00048 {
00049 vpr::DebugOutputGuard dbg_output(gadgetDBG_INPUT_MGR, vprDBG_STATE_LVL,
00050       std::string("------------------ GESTURE PROXY config() -----------------\n"),
00051       std::string("\n"));
00052 
00053    vprASSERT(element->getID() == getElementType());
00054 
00055    if ( ! Proxy::config(element) )
00056    {
00057       return false;
00058    }
00059 
00060    mDeviceName = element->getProperty<std::string>("device");
00061 
00062    refresh();
00063 
00064    return true;
00065 }

virtual Input* gadget::GestureProxy::getProxiedInputDevice (  )  [inline, virtual]

Returns a pointer to the base class of the devices being proxied.

Returns:
NULL if no device is proxied.

Implements gadget::Proxy.

Definition at line 136 of file GestureProxy.h.

00137    {
00138       if((NULL == mTypedDevice) || (isStupefied)())
00139          return NULL;
00140 
00141       Input* ret_val = dynamic_cast<Input*>(mTypedDevice);
00142       vprASSERT((ret_val != NULL) && "Cross-cast in GestureProxy failed");
00143       return ret_val;
00144    }


The documentation for this class was generated from the following files:
Generated on Thu Jan 4 10:44:57 2007 for Gadgeteer by  doxygen 1.5.1