#include <gadget/Type/DeviceInterface.h>
Inheritance diagram for gadget::BaseDeviceInterface:


Public Member Functions | |
| BaseDeviceInterface () | |
| virtual | ~BaseDeviceInterface () |
| BaseDeviceInterface (const BaseDeviceInterface &other) | |
| Copy constructor. | |
| void | init (const std::string &proxyName) |
| Initializes the object. | |
| virtual void | refresh () |
| Refreshes the interface based on the current configuration. | |
| std::string | getProxyName () const |
| Returns the name of the proxy. | |
| bool | isConnected () const |
| Identifies whether this device interface is connected to a proxy. | |
Static Public Member Functions | |
| static void | refreshAllInterfaces () |
| Refreshes all the known device interface objects. | |
| static void | refreshAllDevices () |
| Refreshes all the known device interface objects. | |
Protected Attributes | |
| Proxy * | mProxyPtr |
| Ptr to the proxy. | |
| std::string | mProxyName |
| The name of the proxy (or alias) we are looking at. | |
| bool | mNameSet |
| Has the user set a name?? | |
Device interfaces are wrappers that 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 pointer for the proxy.
Definition at line 65 of file DeviceInterface.h.
| gadget::BaseDeviceInterface::BaseDeviceInterface | ( | ) |
Definition at line 43 of file DeviceInterface.cpp.
00044 : mProxyPtr(NULL) 00045 , mProxyName("UnInitialized") 00046 , mNameSet(false) 00047 { 00048 // Keep reference to the interface. 00049 BaseDeviceInterface::addDevInterface(this); 00050 }
| gadget::BaseDeviceInterface::~BaseDeviceInterface | ( | ) | [virtual] |
Definition at line 52 of file DeviceInterface.cpp.
00053 { 00054 // Remove it from the list of active interfaces. 00055 BaseDeviceInterface::removeDevInterface(this); 00056 }
| gadget::BaseDeviceInterface::BaseDeviceInterface | ( | const BaseDeviceInterface & | other | ) |
Copy constructor.
Definition at line 59 of file DeviceInterface.cpp.
00060 : mProxyPtr(other.mProxyPtr) 00061 , mProxyName(other.mProxyName) 00062 , mNameSet(other.mNameSet) 00063 { 00064 // Keep reference to the interface. 00065 BaseDeviceInterface::addDevInterface(this); 00066 }
| void gadget::BaseDeviceInterface::init | ( | const std::string & | proxyName | ) |
Initializes the object.
| proxyName | String name of the proxy to connect to. |
Definition at line 68 of file DeviceInterface.cpp.
References mNameSet, mProxyName, and refresh().
Referenced by gadget::SimRelativePosition::config(), gadget::SimInput::config(), and gadget::InputLogger::config().
00069 { 00070 mProxyName = proxyName; // Set the name 00071 mNameSet = true; 00072 refresh(); // Refresh the name 00073 }
| void gadget::BaseDeviceInterface::refresh | ( | ) | [virtual] |
Refreshes the interface based on the current configuration.
This method is called by refreshAllInterfaces when system
Reimplemented in gadget::DeviceInterface< PROXY_TYPE >.
Definition at line 77 of file DeviceInterface.cpp.
References mNameSet, mProxyName, and mProxyPtr.
Referenced by init(), and gadget::DeviceInterface< PROXY_TYPE >::refresh().
00078 { 00079 Proxy* prev_proxy_ptr = mProxyPtr; // Keep track of previous value 00080 00081 // If it is not initialized, then don't try 00082 if ( ! mNameSet ) 00083 { 00084 return; 00085 } 00086 00087 mProxyPtr = InputManager::instance()->getProxy(mProxyName); 00088 00089 if (NULL == mProxyPtr) 00090 { 00091 vprDEBUG(vprDBG_ALL,vprDBG_CONFIG_LVL) 00092 << "WARNING: DeviceInterface::refresh: could not find proxy: " 00093 << mProxyName.c_str() << std::endl << vprDEBUG_FLUSH; 00094 vprDEBUG(vprDBG_ALL,vprDBG_CONFIG_LVL) 00095 << " Make sure the proxy exists in the current configuration." 00096 << std::endl << vprDEBUG_FLUSH; 00097 vprDEBUG(vprDBG_ALL,vprDBG_CONFIG_LVL) 00098 << " referencing device interface will be stupefied to point at dummy device." 00099 << std::endl << vprDEBUG_FLUSH; 00100 } 00101 // ASSERT: We have just gotten a valid proxy to point to 00102 else if((NULL != mProxyPtr) && (NULL == prev_proxy_ptr)) 00103 { 00104 const int item_width(25+12); 00105 //const int type_width(20); 00106 00107 //vprDEBUG(vprDBG_ALL,vprDBG_CONFIG_STATUS_LVL) 00108 // << "DeviceInterface now able to find proxy: " 00109 // << mProxyName.c_str() << " [ " 00110 // << clrSetNORM(clrGREEN) << "OK" << clrRESET << " ]" 00111 // << std::endl << vprDEBUG_FLUSH; 00112 00113 //std::string device_name(""); 00114 //Input* deviceptr = mProxyPtr->getProxiedInputDevice(); 00115 //if (NULL != deviceptr) 00116 //{ 00117 // device_name = deviceptr->getInstanceName(); 00118 //} 00119 00120 vprDEBUG(vprDBG_ALL,vprDBG_CONFIG_STATUS_LVL) 00121 << "DeviceInterface found proxy: " 00122 << std::setiosflags(std::ios::right) 00123 << std::setfill(' ') << std::setw(item_width) << mProxyName 00124 << std::resetiosflags(std::ios::right) << " "; 00125 vprDEBUG_CONTnl(vprDBG_ALL,vprDBG_CONFIG_STATUS_LVL) 00126 << "[ " << clrSetNORM(clrGREEN) << "OK" << clrRESET << " ]"; 00127 vprDEBUG_CONTnl(vprDBG_ALL,vprDBG_CONFIG_STATUS_LVL) 00128 << std::endl << vprDEBUG_FLUSH; 00129 } 00130 }
| std::string gadget::BaseDeviceInterface::getProxyName | ( | ) | const [inline] |
Returns the name of the proxy.
Definition at line 93 of file DeviceInterface.h.
00094 { 00095 return mProxyName; 00096 }
| bool gadget::BaseDeviceInterface::isConnected | ( | ) | const [inline] |
Identifies whether this device interface is connected to a proxy.
Definition at line 99 of file DeviceInterface.h.
00100 { 00101 return (NULL != mProxyPtr); 00102 }
| void gadget::BaseDeviceInterface::refreshAllInterfaces | ( | ) | [static] |
Refreshes all the known device interface objects.
Definition at line 151 of file DeviceInterface.cpp.
Referenced by gadget::InputManager::configRemove(), and refreshAllDevices().
00152 { 00153 for ( unsigned int i = 0; i < mAllocatedDevices.size(); ++i ) 00154 { 00155 BaseDeviceInterface* dev = mAllocatedDevices[i]; 00156 dev->refresh(); 00157 } 00158 }
| void gadget::BaseDeviceInterface::refreshAllDevices | ( | ) | [static] |
Refreshes all the known device interface objects.
Definition at line 160 of file DeviceInterface.cpp.
References refreshAllInterfaces().
00161 { 00162 vprDEBUG(vprDBG_ALL, vprDBG_WARNING_LVL) 00163 << clrOutBOLD(clrYELLOW, "NOTICE:") 00164 << " gadget::BaseDeviceInterface::refreshAllDevices() has been replaced" 00165 << std::endl; 00166 vprDEBUG_NEXTnl(vprDBG_ALL, vprDBG_WARNING_LVL) 00167 << "by gadget::BaseDeviceInterface::refreshAllInterfaces()." 00168 << std::endl << vprDEBUG_FLUSH; 00169 refreshAllInterfaces(); 00170 }
Proxy* gadget::BaseDeviceInterface::mProxyPtr [protected] |
Ptr to the proxy.
Definition at line 105 of file DeviceInterface.h.
Referenced by gadget::DeviceInterface< PROXY_TYPE >::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< PROXY_TYPE >::refresh(), refresh(), and gadget::DeviceInterface< PROXY_TYPE >::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< PROXY_TYPE >::setProxy().
1.5.1