Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Examples  

gadget::BaseDeviceInterface Class Reference

Base class for simplified proxy interfaces. More...

#include <DeviceInterface.h>

Inheritance diagram for gadget::BaseDeviceInterface:

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

Collaboration graph
[legend]
List of all members.

Public Methods

 BaseDeviceInterface (const BaseDeviceInterface &other)
 BaseDeviceInterface ()
virtual ~BaseDeviceInterface ()
void init (const std::string proxyName)
 Initializes the object. More...

virtual void refresh ()
 NOTE: If the interface does not have an initialized mProxyName, then don't try to refresh it. More...

std::string getProxyName ()
 Returns the name of the proxy. More...

bool isConnected ()

Static Public Methods

void refreshAllDevices ()

Protected Attributes

ProxymProxyPtr
 Ptr to the proxy. More...

std::string mProxyName
 The name of the proxy (or alias) we are looking at. More...

bool mNameSet
 Has the user set a name?? More...


Detailed Description

Base class for simplified proxy interfaces.

Wrapper to provide an easier way to access proxy objects from within user applications.

Users can simply declare a local interface variable and use it as a smart_ptr for the proxy.

Note:
The init function should be called in the init function of the user application.

Definition at line 65 of file DeviceInterface.h.


Constructor & Destructor Documentation

gadget::BaseDeviceInterface::BaseDeviceInterface const BaseDeviceInterface &    other [inline]
 

Definition at line 68 of file DeviceInterface.h.

Referenced by gadget::DeviceInterface< DigitalProxy >::DeviceInterface, and refreshAllDevices.

00069       : mProxyName(other.mProxyName),
00070         mNameSet(other.mNameSet)
00071    {
00072       BaseDeviceInterface::addDevInterface(this);    // Keep reference to the interface
00073    }

gadget::BaseDeviceInterface::BaseDeviceInterface  
 

Definition at line 43 of file DeviceInterface.cpp.

00044 : mProxyPtr(NULL), mProxyName("UnInitialized"), mNameSet(false)
00045 {
00046    BaseDeviceInterface::addDevInterface(this);    // Keep reference to the interface
00047 }

gadget::BaseDeviceInterface::~BaseDeviceInterface   [virtual]
 

Definition at line 49 of file DeviceInterface.cpp.

00050 {
00051    BaseDeviceInterface::removeDevInterface(this);     // Remove it from the list of active interfaces;
00052 }


Member Function Documentation

void gadget::BaseDeviceInterface::init const std::string    proxyName
 

Initializes the object.

Parameters:
proxyName  String name of the proxy to connect to.

Definition at line 55 of file DeviceInterface.cpp.

References mNameSet, mProxyName, and refresh.

Referenced by gadget::InputLogger::config.

00056 {
00057    mProxyName = proxyName;    // Set the name
00058    mNameSet = true;
00059    refresh();                 // Refresh the name
00060 }

void gadget::BaseDeviceInterface::refresh   [virtual]
 

NOTE: If the interface does not have an initialized mProxyName, then don't try to refresh it.

Postcondition:
(mProxyIndex == -1) ==> Proxy not initi.ized yet
(mProxyIndex != -1) ==> mProxyName has name of device && local proxy ptr is set to the device

Reimplemented in gadget::DeviceInterface.

Definition at line 64 of file DeviceInterface.cpp.

References mNameSet, mProxyName, and mProxyPtr.

Referenced by init.

00065 {
00066    Proxy* prev_proxy_ptr = mProxyPtr;    // Keep track of previous value
00067 
00068    // If it is not initialized, then don't try
00069    if(!mNameSet)
00070    { return; }
00071 
00072    mProxyPtr = InputManager::instance()->getProxy(mProxyName); 
00073 
00074    if (NULL == mProxyPtr)
00075    {
00076       vprDEBUG(vprDBG_ALL,vprDBG_CONFIG_LVL)
00077          << "WARNING: DeviceInterface::refresh: could not find proxy: "
00078          << mProxyName.c_str() << std::endl << vprDEBUG_FLUSH;
00079       vprDEBUG(vprDBG_ALL,vprDBG_CONFIG_LVL)
00080          << "         Make sure the proxy exists in the current configuration."
00081          << std::endl << vprDEBUG_FLUSH;
00082       vprDEBUG(vprDBG_ALL,vprDBG_CONFIG_LVL)
00083          << "   referencing device interface will be stupified to point at dummy device."
00084          << std::endl << vprDEBUG_FLUSH;
00085    }
00086    else if((NULL != mProxyPtr) && (NULL == prev_proxy_ptr))   // ASSERT: We have just gotten a valid proxy to point to
00087    {
00088       const int item_width(25+12);
00089       //const int type_width(20);
00090 
00091       //vprDEBUG(vprDBG_ALL,vprDBG_CONFIG_STATUS_LVL)
00092       //   << "DeviceInterface now able to find proxy: "
00093       //   << mProxyName.c_str() << "               [ "
00094       //   << clrSetNORM(clrGREEN) << "OK" << clrRESET << " ]" << std::endl << vprDEBUG_FLUSH;
00095       
00096       //std::string device_name("");
00097       //Input* deviceptr = mProxyPtr->getProxiedInputDevice();
00098       //if (NULL != deviceptr)
00099       //{
00100       //   device_name = deviceptr->getInstanceName();
00101       //}                                             
00102 
00103       vprDEBUG(vprDBG_ALL,vprDBG_CONFIG_STATUS_LVL)
00104          << "DeviceInterface found proxy: " << std::setiosflags(std::ios::right)
00105          << std::setfill(' ') << std::setw(item_width) << mProxyName
00106          << std::resetiosflags(std::ios::right) << "  ";
00107       vprDEBUG_CONTnl(vprDBG_ALL,vprDBG_CONFIG_STATUS_LVL) << "[ " << clrSetNORM(clrGREEN) << "OK" << clrRESET << " ]";
00108       vprDEBUG_CONTnl(vprDBG_ALL,vprDBG_CONFIG_STATUS_LVL) << std::endl << vprDEBUG_FLUSH;
00109    }
00110 }

std::string gadget::BaseDeviceInterface::getProxyName   [inline]
 

Returns the name of the proxy.

Definition at line 94 of file DeviceInterface.h.

00095    {
00096       return mProxyName;
00097    }

bool gadget::BaseDeviceInterface::isConnected   [inline]
 

Definition at line 99 of file DeviceInterface.h.

00100    {
00101       return (NULL != mProxyPtr);
00102    }

void gadget::BaseDeviceInterface::refreshAllDevices   [static]
 

Definition at line 127 of file DeviceInterface.cpp.

References BaseDeviceInterface.

00128 {
00129    for(unsigned int i=0;i<mAllocatedDevices.size();i++)
00130    {
00131       BaseDeviceInterface* dev = mAllocatedDevices[i];
00132       dev->refresh();
00133    }
00134 }


Member Data Documentation

Proxy* gadget::BaseDeviceInterface::mProxyPtr [protected]
 

Ptr to the proxy.

Definition at line 105 of file DeviceInterface.h.

Referenced by gadget::DeviceInterface< DigitalProxy >::refresh, and refresh.

std::string gadget::BaseDeviceInterface::mProxyName [protected]
 

The name of the proxy (or alias) we are looking at.

Definition at line 106 of file DeviceInterface.h.

Referenced by init, gadget::DeviceInterface< DigitalProxy >::refresh, refresh, and gadget::DeviceInterface< DigitalProxy >::setProxy.

bool gadget::BaseDeviceInterface::mNameSet [protected]
 

Has the user set a name??

Definition at line 107 of file DeviceInterface.h.

Referenced by init, refresh, and gadget::DeviceInterface< DigitalProxy >::setProxy.


The documentation for this class was generated from the following files:
Generated on Sun May 2 14:26:55 2004 for Gadgeteer by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002