- Timestamp:
- 05/01/07 14:55:06 (2 years ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
juggler/trunk/modules/gadgeteer/gadget/Type/DeviceInterface.h
r19729 r20061 31 31 #include <vector> 32 32 #include <gadget/Util/Debug.h> 33 #include <gadget/Type/ProxyPtr.h> 33 34 34 35 #include <boost/concept_check.hpp> … … 36 37 namespace gadget 37 38 { 38 39 class Proxy;40 class AnalogProxy;41 class DigitalProxy;42 class GestureProxy;43 class GloveProxy;44 class KeyboardMouseProxy;45 class PositionProxy;46 class StringProxy;47 class CommandProxy;48 39 49 40 /** \class BaseDeviceInterface DeviceInterface.h gadget/Type/DeviceInterface.h … … 93 84 bool isConnected() const 94 85 { 95 return (NULL != mProxyPtr );86 return (NULL != mProxyPtr.get()); 96 87 } 97 88 98 89 protected: 99 Proxy *mProxyPtr; /**< Ptr to the proxy */90 ProxyPtr mProxyPtr; /**< Ptr to the proxy */ 100 91 std::string mProxyName; /**< The name of the proxy (or alias) we are looking at */ 101 92 bool mNameSet; /**< Has the user set a name?? */ … … 136 127 : BaseDeviceInterface(other) 137 128 { 138 if (other.mTypeSpecificProxy != NULL) 129 mDummyProxy = boost::shared_ptr<PROXY_TYPE>(new PROXY_TYPE); 130 131 if (NULL != other.mTypeSpecificProxy.get()) 139 132 { 140 133 mTypeSpecificProxy = other.mTypeSpecificProxy; … … 142 135 else 143 136 { 144 mTypeSpecificProxy = &mDummyProxy;137 mTypeSpecificProxy = mDummyProxy; 145 138 } 146 139 } … … 150 143 : BaseDeviceInterface() 151 144 { 152 mTypeSpecificProxy = &mDummyProxy; 145 mDummyProxy = boost::shared_ptr<PROXY_TYPE>(new PROXY_TYPE); 146 mTypeSpecificProxy = mDummyProxy; 153 147 } 154 148 … … 167 161 * @see init() 168 162 */ 169 PROXY_TYPE*operator->()163 boost::shared_ptr<PROXY_TYPE> operator->() 170 164 { 171 165 return mTypeSpecificProxy; … … 186 180 187 181 /** Returns the underlying proxy to which we are connected. */ 188 PROXY_TYPE*getProxy()182 boost::shared_ptr<PROXY_TYPE> getProxy() 189 183 { 190 184 return mTypeSpecificProxy; … … 206 200 { 207 201 BaseDeviceInterface::refresh(); 208 if( mProxyPtr != NULL)209 { 210 mTypeSpecificProxy = dynamic_cast<PROXY_TYPE*>(mProxyPtr);211 if(NULL == mTypeSpecificProxy )202 if(NULL!= mProxyPtr.get()) 203 { 204 mTypeSpecificProxy = boost::dynamic_pointer_cast<PROXY_TYPE>(mProxyPtr); 205 if(NULL == mTypeSpecificProxy.get()) 212 206 { 213 207 vprDEBUG(gadgetDBG_INPUT_MGR, vprDBG_CRITICAL_LVL) … … 220 214 221 215 // If either one of the proxy pointers are NULL, then use a dummy 222 if((NULL == mProxyPtr ) || (NULL == mTypeSpecificProxy))223 { 224 mTypeSpecificProxy = &mDummyProxy;216 if((NULL == mProxyPtr.get()) || (NULL == mTypeSpecificProxy.get())) 217 { 218 mTypeSpecificProxy = mDummyProxy; 225 219 } 226 220 } 227 221 228 222 private: 229 PROXY_TYPE*mTypeSpecificProxy; /**< The proxy that is being wrapped */230 PROXY_TYPEmDummyProxy;223 boost::shared_ptr<PROXY_TYPE> mTypeSpecificProxy; /**< The proxy that is being wrapped */ 224 boost::shared_ptr<PROXY_TYPE> mDummyProxy; 231 225 }; 232 226 233 227 234 228 // --- Typedefs to the old types --- // 235 typedef DeviceInterface< AnalogProxy> AnalogInterface;236 typedef DeviceInterface< DigitalProxy> DigitalInterface;237 typedef DeviceInterface< GestureProxy> GestureInterface;238 typedef DeviceInterface< GloveProxy> GloveInterface;239 typedef DeviceInterface< KeyboardMouseProxy> KeyboardMouseInterface;240 typedef DeviceInterface< PositionProxy> PositionInterface;241 typedef DeviceInterface< CommandProxy> CommandInterface;242 typedef DeviceInterface< StringProxy> StringInterface;229 typedef DeviceInterface<class AnalogProxy> AnalogInterface; 230 typedef DeviceInterface<class DigitalProxy> DigitalInterface; 231 typedef DeviceInterface<class GestureProxy> GestureInterface; 232 typedef DeviceInterface<class GloveProxy> GloveInterface; 233 typedef DeviceInterface<class KeyboardMouseProxy> KeyboardMouseInterface; 234 typedef DeviceInterface<class PositionProxy> PositionInterface; 235 typedef DeviceInterface<class CommandProxy> CommandInterface; 236 typedef DeviceInterface<class StringProxy> StringInterface; 243 237 244 238 } // end namespace
