1 |
/* |
---|
2 |
* Copyright (C) 2005-2008 by Pieter Palmers |
---|
3 |
* |
---|
4 |
* This file is part of FFADO |
---|
5 |
* FFADO = Free Firewire (pro-)audio drivers for linux |
---|
6 |
* |
---|
7 |
* FFADO is based upon FreeBoB. |
---|
8 |
* |
---|
9 |
* This program is free software: you can redistribute it and/or modify |
---|
10 |
* it under the terms of the GNU General Public License as published by |
---|
11 |
* the Free Software Foundation, either version 2 of the License, or |
---|
12 |
* (at your option) version 3 of the License. |
---|
13 |
* |
---|
14 |
* This program is distributed in the hope that it will be useful, |
---|
15 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
16 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
17 |
* GNU General Public License for more details. |
---|
18 |
* |
---|
19 |
* You should have received a copy of the GNU General Public License |
---|
20 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
---|
21 |
* |
---|
22 |
*/ |
---|
23 |
|
---|
24 |
#ifndef __FFADO_DEVICESTRINGPARSER__ |
---|
25 |
#define __FFADO_DEVICESTRINGPARSER__ |
---|
26 |
|
---|
27 |
#include "debugmodule/debugmodule.h" |
---|
28 |
|
---|
29 |
#include <vector> |
---|
30 |
#include <string> |
---|
31 |
|
---|
32 |
class ConfigRom; |
---|
33 |
|
---|
34 |
class DeviceStringParser { |
---|
35 |
|
---|
36 |
protected: |
---|
37 |
class DeviceString { |
---|
38 |
public: |
---|
39 |
enum eType { |
---|
40 |
eInvalid = 0, |
---|
41 |
eBusNode = 1, // old-style hw:bus,node |
---|
42 |
eGUID = 2, // GUID match |
---|
43 |
}; |
---|
44 |
|
---|
45 |
DeviceString(DeviceStringParser&); |
---|
46 |
~DeviceString(); |
---|
47 |
|
---|
48 |
bool parse(std::string s); |
---|
49 |
bool match(ConfigRom &); |
---|
50 |
|
---|
51 |
std::string getString() {return m_String;}; |
---|
52 |
void show(); |
---|
53 |
|
---|
54 |
bool operator==(const DeviceString& x); |
---|
55 |
static bool isValidString(std::string s); |
---|
56 |
|
---|
57 |
private: |
---|
58 |
DeviceStringParser & m_Parent; |
---|
59 |
|
---|
60 |
int m_node; |
---|
61 |
int m_port; |
---|
62 |
uint64_t m_guid; |
---|
63 |
std::string m_String; |
---|
64 |
enum eType m_Type; |
---|
65 |
|
---|
66 |
DECLARE_DEBUG_MODULE_REFERENCE; |
---|
67 |
}; |
---|
68 |
|
---|
69 |
public: |
---|
70 |
DeviceStringParser(); |
---|
71 |
virtual ~DeviceStringParser(); |
---|
72 |
|
---|
73 |
int countDeviceStrings() {return m_DeviceStrings.size();}; |
---|
74 |
|
---|
75 |
bool match(ConfigRom &); |
---|
76 |
|
---|
77 |
bool parseString(std::string s); |
---|
78 |
void show(); |
---|
79 |
void setVerboseLevel(int i); |
---|
80 |
|
---|
81 |
static bool isValidString(std::string s); |
---|
82 |
|
---|
83 |
protected: |
---|
84 |
bool removeDeviceString(DeviceString *); |
---|
85 |
bool addDeviceString(DeviceString *); |
---|
86 |
bool hasDeviceString(DeviceString *); |
---|
87 |
|
---|
88 |
private: |
---|
89 |
int findDeviceString(DeviceString *); |
---|
90 |
|
---|
91 |
void pruneDuplicates(); |
---|
92 |
|
---|
93 |
typedef std::vector< DeviceString* > DeviceStringVector; |
---|
94 |
typedef std::vector< DeviceString* >::iterator DeviceStringVectorIterator; |
---|
95 |
DeviceStringVector m_DeviceStrings; |
---|
96 |
|
---|
97 |
protected: |
---|
98 |
DECLARE_DEBUG_MODULE; |
---|
99 |
|
---|
100 |
}; |
---|
101 |
|
---|
102 |
#endif /* __FFADO_DEVICESTRINGPARSER__ */ |
---|
103 |
|
---|
104 |
|
---|