/* This software is subject to the license described in the License.txt file included with this software distribution. You may not use this file except in compliance with this license. Copyright (c) Dynastream Innovations Inc. 2016 All rights reserved. */ #include "types.h" #include #include //#include "usb_device_handle_si.hpp" //#include "usb_device_handle_libusb.hpp" //#include //using namespace std; /* struct SI { static const USHORT ANT_VID = 0x0FCF; static const USHORT ANT_PID = 0x1004; //defines used by AutoInit static const UCHAR ANT_PRODUCT_DESCRIPTION[255]; static const USHORT DEFAULT_BAUD_RATE = 50000; }; const UCHAR SI::ANT_PRODUCT_DESCRIPTION[255] = "Dynastream USB Interface Board"; //"ANT USB Stick" auto_ptr ANTDeviceList::GetDeviceList(ULONG ulDeviceTypeField_) { return auto_ptr(new ANTDeviceList(ulDeviceTypeField_)); } /* void USBDeviceList::FreeDeviceList(const USBDeviceList*& pclDeviceList_) { delete pclDeviceList_; pclDeviceList_ = NULL; return; } *//* ANTDeviceList::ANTDeviceList(ULONG ulDeviceTypeField_) : USBDeviceList() { if( (ulDeviceTypeField_ & DeviceType::SI_LABS) != 0) { const list clDeviceSIList = USBDeviceHandleSI::GetDeviceList(); //!!There is a list copy here! //clDeviceList.insert(clDeviceList.end(), clDeviceSIList.begin(), clDeviceSIList.end()); //!!do we have to make an iterator? Add(clDeviceSIList.begin(), clDeviceSIList.end()); } if( (ulDeviceTypeField_ & DeviceType::LIBUSB) != 0) { const list clDeviceLibusbList = USBDeviceHandleLibusb::GetDeviceList(); //clDeviceList.insert(clDeviceList.end(), clDeviceLibusbList.begin(), clDeviceLibusbList.end()); //!!do we have to make an iterator? Add(clDeviceLibusbList.begin(), clDeviceLibusbList.end()); } //ulSize = clDeviceList.size(); return; } ANTDeviceList::~ANTDeviceList() { /* list::iterator i; for(i = clDeviceList.begin(); i != clDeviceList.end(); i++) { const USBDevice*& pclDevice = *i; if(pclDevice != NULL) { delete pclDevice; //!!Make sure the device specific lists do not delete what they give to us pclDevice = NULL; } } clDeviceList.clear(); ulSize = 0; *//* return; } */ #define USBTemplateDeviceList USBDeviceList /* template template USBTemplateDeviceList::USBDeviceList(const Container_& tContainer_) { Add(tContainer_.begin(), tContainer_.end()); return; } */ template USBTemplateDeviceList::~USBDeviceList() { Clear(); return; } template template USBTemplateDeviceList::USBDeviceList(InputIterator tFirst_, InputIterator tLast_) { Add(tFirst_, tLast_); return; } template USBTemplateDeviceList::USBDeviceList(const USBTemplateDeviceList& clDeviceList_) { Add(clDeviceList_); return; } template template USBTemplateDeviceList::USBDeviceList(const USBDeviceList& clDeviceList_) { Add(clDeviceList_); return; } template USBTemplateDeviceList& USBTemplateDeviceList::operator=(const USBTemplateDeviceList& clDeviceList_) { if(this == &clDeviceList_) return *this; Clear(); Add(clDeviceList_); return *this; } template template USBTemplateDeviceList& USBTemplateDeviceList::operator=(const USBDeviceList& clDeviceList_) { if(this == &clDeviceList_) return *this; Clear(); Add(clDeviceList_); return *this; } template template void USBTemplateDeviceList::Add(InputIterator tFirst_, InputIterator tLast_) { for(InputIterator i=tFirst_; i != tLast_; i++) Add(*i); //insert(clDeviceList.end(), tFirst_, tLast_); return; } template template void USBTemplateDeviceList::Add(const USBDeviceList& clDeviceList_) { ULONG ulSize = clDeviceList_.GetSize(); for(ULONG i=0; i void USBTemplateDeviceList::Add(const USBDeviceType& tDevice_) //!!Return the address of the element? Then we don't need GetAddress(). { //Container::const_iterator clIterator; //advance(clIterator, ulSize); clDeviceList.insert(clDeviceList.end(), new USBDeviceType(tDevice_)); //clDeviceList.push_back(tDevice_); //!! container universal? return; } template void USBTemplateDeviceList::Clear() { size_t uiSize = clDeviceList.size(); for(size_t i=0; i USBTemplateDeviceList USBTemplateDeviceList::GetSubList(typename USBDeviceList::CompareFunc pfCompareFunc_) const //!!Copy! { USBTemplateDeviceList clSubList; if(pfCompareFunc_ == NULL) return clSubList; typename Container::const_iterator clIterator; for(clIterator = clDeviceList.begin(); clIterator != clDeviceList.end(); clIterator++) { USBDeviceType const& tDevice = **clIterator; if(pfCompareFunc_(tDevice) == TRUE) clSubList.Add(tDevice); } return clSubList; } template const USBDeviceType& USBTemplateDeviceList::operator[](ULONG ulNum_) const { if(ulNum_ >= clDeviceList.size()) throw 0; //!! typename Container::const_iterator clIterator; clIterator = clDeviceList.begin(); std::advance(clIterator, ulNum_); return **clIterator; } template const USBDeviceType* USBTemplateDeviceList::GetAddress(ULONG ulNum_) const { if(ulNum_ >= clDeviceList.size()) throw 0; //!! typename Container::const_iterator clIterator; clIterator = clDeviceList.begin(); std::advance(clIterator, ulNum_); return *clIterator; }