Develop and Download Open Source Software

Browse Subversion Repository

Contents of /connection/ConnectionDeviceSearch.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 279 - (show annotations) (download) (as text)
Wed Mar 12 05:28:19 2008 UTC (16 years, 1 month ago) by satofumi
File MIME type: text/x-c++src
File size: 1668 byte(s)
adjust tab index
1 /*!
2 \file
3 \brief ť•i”ԍ†‚É‚ć‚éÚ‘ą
4
5 \author Satofumi KAMIMURA
6
7 $Id$
8 */
9
10 #include "ConnectionDeviceSearch.h"
11 #include "ProductIdHandler.h"
12 #include <string>
13 #include <algorithm>
14
15 using namespace beego;
16
17
18 struct ConnectionDeviceSearch::pImpl {
19 typedef std::vector<std::string> DeviceList;
20 DeviceList devices;
21 };
22
23
24 ConnectionDeviceSearch::ConnectionDeviceSearch(void) : pimpl(new pImpl) {
25 }
26
27
28 ConnectionDeviceSearch::~ConnectionDeviceSearch(void) {
29 }
30
31
32 void ConnectionDeviceSearch::add(const char* device) {
33 pimpl->devices.push_back(device);
34 }
35
36
37 void ConnectionDeviceSearch::remove(const char* device) {
38 pImpl::DeviceList::iterator p =
39 find(pimpl->devices.begin(), pimpl->devices.end(), device);
40 if (p == pimpl->devices.end()) {
41 return;
42 }
43
44 // íœ
45 pimpl->devices.erase(p);
46 }
47
48
49 void ConnectionDeviceSearch::clear(void) {
50 pimpl->devices.clear();
51 }
52
53
54 size_t ConnectionDeviceSearch::getLeftDevices(std::vector<std::string>&
55 devices) {
56 devices = pimpl->devices;
57 return pimpl->devices.size();
58 }
59
60
61 bool ConnectionDeviceSearch::search(std::string& find_device,
62 const ProductIdHandler* handler,
63 const char* productId) {
64
65 for (pImpl::DeviceList::iterator it = pimpl->devices.begin();
66 it != pimpl->devices.end(); ++it) {
67 const char* try_device = it->c_str();
68 if (handler->checkProductId(it->c_str(), productId)) {
69 find_device = try_device;
70 remove(find_device.c_str());
71 return true;
72 }
73 }
74 return false;
75 }
76
77
78 size_t ConnectionDeviceSearch::size(void) {
79 return pimpl->devices.size();
80 }

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26