gadget::CommandProxy Class Reference

A proxy class to command-oriented devices, used by the Input Manager. More...

#include <gadget/Type/CommandProxy.h>

Inheritance diagram for gadget::CommandProxy:

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

Collaboration graph
[legend]
List of all members.

Public Member Functions

virtual void updateData ()
virtual vpr::Interval getTimeStamp () const
 Returns the time of the last update.
int getData () const
 Gets the command data.
CommandDatagetCommandData ()
CommandgetCommandPtr ()
 Returns a pointer to the gadget::Command object that we are proxying.
int getUnit () const
 Returns the unit index into the string speech recognition device from which this proxy is reading data.
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

A proxy class to command-oriented devices, used by the Input Manager.

A command proxy always points to a command-oriented device and unit number within that device. The Input Manager can therefore keep an array of these around and treat them as command devices that only return a single sub-device's amount of data (one int).

See also:
gagdet::Command

Definition at line 55 of file CommandProxy.h.


Constructor & Destructor Documentation

gadget::CommandProxy::CommandProxy (  )  [inline]

Definition at line 61 of file CommandProxy.h.

00062       : mUnitNum(-1), mData(0)
00063    {;}

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

Definition at line 65 of file CommandProxy.h.

00066    {;}

gadget::CommandProxy::CommandProxy (  )  [inline]

Definition at line 61 of file CommandProxy.h.

00062       : mUnitNum(-1), mData(0)
00063    {;}

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

Definition at line 65 of file CommandProxy.h.

00066    {;}


Member Function Documentation

void gadget::CommandProxy::updateData (  )  [virtual]

Reimplemented from gadget::Proxy.

Definition at line 66 of file CommandProxy.cpp.

References getProxiedInputDevice(), gadget::Proxy::isStupefied(), gadget::TypedProxy< DEV_TYPE >::mTypedDevice, and gadget::Input::updateDataIfNeeded().

00067 {
00068    if (!isStupefied())
00069    {
00070       // Make sure dependencies are updated.
00071       getProxiedInputDevice()->updateDataIfNeeded();
00072       mData = mTypedDevice->getCommandData(mUnitNum);
00073    }
00074 }

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

Returns the time of the last update.

Implements gadget::Proxy.

Definition at line 72 of file CommandProxy.h.

00073    {
00074       return mData.getTime();
00075    }

int gadget::CommandProxy::getData (  )  const [inline]

Gets the command data.

Definition at line 80 of file CommandProxy.h.

00081    {
00082       // If we're stupefied, return 0, return the current command value.
00083       return (isStupefied() ? 0 : mData.getDigital());
00084    }

CommandData* gadget::CommandProxy::getCommandData (  )  [inline]

Definition at line 86 of file CommandProxy.h.

00087    {
00088       return &mData;
00089    }

Command* gadget::CommandProxy::getCommandPtr (  )  [inline]

Returns a pointer to the gadget::Command object that we are proxying.

Definition at line 94 of file CommandProxy.h.

00095    {
00096       // If we're stupefied, return NULL.  Otherwise, return mTypedDevice.
00097       return (isStupefied() ? NULL : mTypedDevice);
00098    }

int gadget::CommandProxy::getUnit (  )  const [inline]

Returns the unit index into the string speech recognition device from which this proxy is reading data.

Definition at line 104 of file CommandProxy.h.

00105    {
00106       return mUnitNum;
00107    }

std::string gadget::CommandProxy::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 41 of file CommandProxy.cpp.

Referenced by config().

00042 {
00043    return "command_proxy";
00044 }

bool gadget::CommandProxy::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 46 of file CommandProxy.cpp.

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

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

virtual Input* gadget::CommandProxy::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 113 of file CommandProxy.h.

Referenced by updateData().

00114    {
00115       if((NULL == mTypedDevice) || (mStupefied))
00116       {
00117          return NULL;
00118       }
00119 
00120       Input* ret_val = dynamic_cast<Input*>(mTypedDevice);
00121       vprASSERT((ret_val != NULL) && "Cross-cast in Command failed");
00122       return ret_val;
00123    }


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