[Libphidget-cvs-commits] CVS: libphidget/src/phidget++ CPhidgetManager.cc,1.14,1.15 CPhidgetManager.
Status: Alpha
Brought to you by:
jstrohm
|
From: Jack S. <js...@us...> - 2002-12-21 03:31:43
|
Update of /cvsroot/libphidget/libphidget/src/phidget++
In directory sc8-pr-cvs1:/tmp/cvs-serv16418
Modified Files:
CPhidgetManager.cc CPhidgetManager.h
Log Message:
More documentation
Index: CPhidgetManager.cc
===================================================================
RCS file: /cvsroot/libphidget/libphidget/src/phidget++/CPhidgetManager.cc,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** CPhidgetManager.cc 18 Dec 2002 02:51:17 -0000 1.14
--- CPhidgetManager.cc 21 Dec 2002 03:31:39 -0000 1.15
***************
*** 41,76 ****
}
- /*
- void CPhidgetManager::addPossibleNewDevice(struct phidget *dev)
- {
-
- // Does this device already exists?
- for (int t=0;t<_phidgets.size();t++)
- {
- // We found already existing device, don't have to do anything
- // the underlying library has already attached it
- if (_phidgets[t]->_device==dev)
- return;
- }
-
- if (phidget_open(dev)==NULL)
- throw runtime_error("Can't open phidget.");
-
- // What type of device is this?
- switch(dev->type->deviceClass)
- {
- case SERVO_CONTROLLER:
- _phidgets.push_back(new CServoController(dev));
- break;
- case INTERFACE_KIT:
- _phidgets.push_back(new CInterfaceKit(dev));
- break;
- case OTHER:
- phidget_close(dev);
- break;
- }
- }
- */
-
CPhidgetManager::CPhidgetManager ()
{
--- 41,44 ----
***************
*** 79,96 ****
error(phidgetInit(1));
- /*
- // Build classes to handle and open all devices
-
- int phidget_count;
- struct phidget **phidgets=phidget_get_phidgets(&phidget_count);
-
- for (int t=0;t<phidget_count;t++)
- {
- // We open this device
- addPossibleNewDevice(phidgets[t]);
- }
-
- for (int t=0;t<_phidgets.size();t++) _phidgets[t]->processEvents();
- */
METHOD_UNGUARD;
}
--- 47,50 ----
***************
*** 99,113 ****
{
METHOD_GUARD;
- /*
- for (int t=0;t<_phidgets.size();t++)
- {
- if (_phidgets[t]->userConstructed())
- throw runtime_error("All user constructed phidgets must be deleted before the phidget manager is destroyed.");
-
- delete _phidgets[t];
- }
- */
error(phidgetDeinit());
METHOD_UNGUARD;
}
--- 53,59 ----
{
METHOD_GUARD;
error(phidgetDeinit());
+
METHOD_UNGUARD;
}
***************
*** 118,124 ****
set < CUID >devices;
-
-
-
// Ask libphidget for any known phidgets, these would be real Phidgets
// and nothing else
--- 64,67 ----
***************
*** 190,205 ****
}
-
- //CPhidget *CPhidgetManager::phidget(const CUID &uid)
- //{
- //// do we have a phidget with this id?
- //return(dynamic_cast<CPhidget *>(find(uid)));
- //}
-
- //CServoController *CPhidgetManager::servoController(const CUID &uid)
- //{
- //return(dynamic_cast<CServoController *>(find(uid)));
- //}
-
bool CPhidgetManager::checkForEvents()
{
--- 133,136 ----
***************
*** 226,230 ****
// Is this a phidget or a phidget device we are trying to find?
-
// Look at all known devices for this
for (int t = 0; t < _uniqueDevices.size(); t++)
--- 157,160 ----
***************
*** 314,330 ****
METHOD_UNGUARD;
}
-
- /*
- CServoController *CPhidgetManager::createServoController(const CUID &uid)
- {
- // Does a device by that ID exists? if so then we have an error
- if (find(uid)!=NULL)
- throw runtime_error("Can't create a default servo controller, because one already exists");
-
- CServoController *sc=new CServoController(uid);
-
- _uniqueDevices.push_back(sc);
-
- return(sc);
- }
- */
--- 244,245 ----
Index: CPhidgetManager.h
===================================================================
RCS file: /cvsroot/libphidget/libphidget/src/phidget++/CPhidgetManager.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** CPhidgetManager.h 17 Dec 2002 23:39:16 -0000 1.7
--- CPhidgetManager.h 21 Dec 2002 03:31:39 -0000 1.8
***************
*** 57,63 ****
friend class CUniqueDevice;
- vector <CUniqueDevice *>_uniqueDevices;
-
CPhidgetManager ();
struct phidget *getDeviceHandle(const CUID &uid);
CPhidget *createPhidget(const CUID &uid);
--- 57,63 ----
friend class CUniqueDevice;
CPhidgetManager ();
+
+ vector <CUniqueDevice *>_uniqueDevices;
struct phidget *getDeviceHandle(const CUID &uid);
CPhidget *createPhidget(const CUID &uid);
***************
*** 66,69 ****
--- 66,70 ----
public:
+
/**
* Deletes all currently allocated phidgets, only called when the application finishes
***************
*** 78,99 ****
* Returns a list of known devices currently available, filters based on tp
*/
! vector <CUID >query(const EDeviceClass tp = LP_PHIDGET);
/**
* Returns a phidget by it's unique ID or NULL if it is not attached
*/
! CPhidget *phidget (const CUID &uid //<! Unique ID of phidget
);
CServoController *servoController(const CUID &uid);
/**
! * Search for any known devices (Phidgets or their sub-devices) that match this
! * unique id
*/
CUniqueDevice *find(const CUID &uid, bool create = false);
/**
! * Check for attach/detach events (or any other events.
*/
bool checkForEvents();
--- 79,105 ----
* Returns a list of known devices currently available, filters based on tp
*/
! vector <CUID >query(
! const EDeviceClass tp = LP_PHIDGET //<! The device class you are querying for
! );
/**
* Returns a phidget by it's unique ID or NULL if it is not attached
*/
! CPhidget *phidget (
! const CUID &uid //<! Unique ID of phidget
);
+ /**
+ * Helper function to return a servo controller that matches the CUID or NULL is not attached.
+ */
CServoController *servoController(const CUID &uid);
/**
! * Search for any known devices (Phidgets or their sub-devices) that match this unique id
*/
CUniqueDevice *find(const CUID &uid, bool create = false);
/**
! * Check for attach/detach events (or any other events).
*/
bool checkForEvents();
|