-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathModemDeviceChecker.cpp
More file actions
42 lines (34 loc) · 1.12 KB
/
Copy pathModemDeviceChecker.cpp
File metadata and controls
42 lines (34 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include "StdAfx.h"
#include "ModemDeviceChecker.h"
using namespace DeviceDetectLibrary;
CModemDeviceChecker::CModemDeviceChecker(ICollector& collector, const std::vector<std::wstring>& patternNames)
: collector_(collector)
{
_patternNames = patternNames;
}
CModemDeviceChecker::~CModemDeviceChecker(void)
{
}
bool CModemDeviceChecker::Check(const CDeviceInfo::Pointer& pDeviceInfo)
{
int searchCount = 0;
std::wstring name = pDeviceInfo->GetName();
for(std::vector<std::wstring>::const_iterator iter = _patternNames.begin(); iter != _patternNames.end(); ++iter)
{
if(name.end() != std::search(name.begin(), name.end(), (*iter).begin(), (*iter).end()))
{
searchCount++;
}
}
return searchCount == _patternNames.size();
}
void CModemDeviceChecker::Collect(const CDeviceInfo::Pointer& pDeviceInfo, const std::wstring& pluginID)
{
if(Check(pDeviceInfo))
{
CDeviceInfo::Pointer pDeviceInfo = CDeviceInfo::Create(
pDeviceInfo->GetId(), pDeviceInfo->GetName(), pDeviceInfo->GetDeviceDisplayName(), pDeviceInfo->GetConnectionInfo());
pDeviceInfo->SetDeviceDisplayName(pluginID);
collector_.Found(pDeviceInfo);
}
}