gadget::DeviceInterface< PROXY_TYPE > Class Template Reference

Type-specific device interface. More...

#include <gadget/Type/DeviceInterface.h>

Inheritance diagram for gadget::DeviceInterface< PROXY_TYPE >:

Inheritance graph
[legend]
Collaboration diagram for gadget::DeviceInterface< PROXY_TYPE >:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 DeviceInterface (const DeviceInterface &other)
 DeviceInterface ()
PROXY_TYPE * getProxy ()
 Returns the underlying proxy to which we are connected.
void setProxy (PROXY_TYPE *proxy)
 Sets the proxy to an explicit proxy.
virtual void refresh ()
 Refreshes the interface based on the current configuration.
Smart pointer operator overloads.
Device interfaces make use of the Smart Pointer design pattern.

Access to the contained device proxy must occur through one of these operators.

PROXY_TYPE * operator-> ()
 Member selection (via pointer) operator overload.
PROXY_TYPE & operator * ()
 Dereference operator overload.

Detailed Description

template<class PROXY_TYPE>
class gadget::DeviceInterface< PROXY_TYPE >

Type-specific device interface.

Definition at line 145 of file DeviceInterface.h.


Constructor & Destructor Documentation

template<class PROXY_TYPE>
gadget::DeviceInterface< PROXY_TYPE >::DeviceInterface ( const DeviceInterface< PROXY_TYPE > &  other  )  [inline]

Definition at line 148 of file DeviceInterface.h.

References gadget::DeviceInterface< PROXY_TYPE >::mTypeSpecificProxy.

00149       : BaseDeviceInterface(other)
00150    {
00151       if (other.mTypeSpecificProxy != NULL)
00152       {
00153          mTypeSpecificProxy = other.mTypeSpecificProxy;
00154       }
00155       else
00156       {
00157          mTypeSpecificProxy = &mDummyProxy;
00158       }
00159    }

template<class PROXY_TYPE>
gadget::DeviceInterface< PROXY_TYPE >::DeviceInterface (  )  [inline]

Definition at line 162 of file DeviceInterface.h.

00163       : BaseDeviceInterface()
00164    {
00165       mTypeSpecificProxy = &mDummyProxy;
00166    }


Member Function Documentation

template<class PROXY_TYPE>
PROXY_TYPE* gadget::DeviceInterface< PROXY_TYPE >::operator-> (  )  [inline]

Member selection (via pointer) operator overload.

Precondition:
init() has been invoked.
See also:
init()

Definition at line 182 of file DeviceInterface.h.

00183    {
00184       return mTypeSpecificProxy;
00185    }

template<class PROXY_TYPE>
PROXY_TYPE& gadget::DeviceInterface< PROXY_TYPE >::operator * (  )  [inline]

Dereference operator overload.

Precondition:
init() has been invoked.
See also:
init()

Definition at line 194 of file DeviceInterface.h.

00195    {
00196       return *(mTypeSpecificProxy);
00197    }

template<class PROXY_TYPE>
PROXY_TYPE* gadget::DeviceInterface< PROXY_TYPE >::getProxy (  )  [inline]

Returns the underlying proxy to which we are connected.

Definition at line 201 of file DeviceInterface.h.

00202    {
00203       return mTypeSpecificProxy;
00204    }

template<class PROXY_TYPE>
void gadget::DeviceInterface< PROXY_TYPE >::setProxy ( PROXY_TYPE *  proxy  )  [inline]

Sets the proxy to an explicit proxy.

Definition at line 207 of file DeviceInterface.h.

References gadget::BaseDeviceInterface::mNameSet, gadget::BaseDeviceInterface::mProxyName, and gadget::DeviceInterface< PROXY_TYPE >::refresh().

00208    {
00209       vprASSERT(NULL != proxy);
00210       mProxyName = proxy->getName();    // Set the name
00211       mNameSet = true;
00212       this->refresh();
00213 
00214       // Verify we found the correct proxy
00215       vprASSERT(mTypeSpecificProxy == proxy && "Found incorrect proxy for dev interface");
00216    }

template<class PROXY_TYPE>
virtual void gadget::DeviceInterface< PROXY_TYPE >::refresh (  )  [inline, virtual]

Refreshes the interface based on the current configuration.

This method is called by refreshAllInterfaces when system

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

Reimplemented from gadget::BaseDeviceInterface.

Definition at line 218 of file DeviceInterface.h.

References gadgetDBG_INPUT_MGR(), gadget::BaseDeviceInterface::mProxyName, gadget::BaseDeviceInterface::mProxyPtr, and gadget::BaseDeviceInterface::refresh().

Referenced by gadget::DeviceInterface< PROXY_TYPE >::setProxy().

00219    {
00220       BaseDeviceInterface::refresh();
00221       if(mProxyPtr != NULL)
00222       {
00223          mTypeSpecificProxy = dynamic_cast<PROXY_TYPE*>(mProxyPtr);
00224          if(NULL == mTypeSpecificProxy)
00225          {
00226             vprDEBUG(gadgetDBG_INPUT_MGR, vprDBG_CRITICAL_LVL)
00227                << "[gadget::DeviceInterface::refresh()] Tried to point at "
00228                << "proxy of incorrect type named '" << mProxyName << "'"
00229                << " it was type:" << typeid(mProxyPtr).name()
00230                << std::endl << vprDEBUG_FLUSH;
00231          }
00232       }
00233 
00234       // If either one of the proxy pointers are NULL, then use a dummy
00235       if((NULL == mProxyPtr) || (NULL == mTypeSpecificProxy))
00236       {
00237          mTypeSpecificProxy = &mDummyProxy;
00238       }
00239    }


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