root/branches/libffado-2.0/src/DeviceStringParser.h

Revision 1545, 2.5 kB (checked in by ppalmers, 15 years ago)

fixes #201

Line 
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     int matchPosition(ConfigRom& c);
77
78     bool parseString(std::string s);
79     void show();
80     void setVerboseLevel(int i);
81
82     static bool isValidString(std::string s);
83
84 protected:
85     bool removeDeviceString(DeviceString *);
86     bool addDeviceString(DeviceString *);
87     bool hasDeviceString(DeviceString *);
88
89 private:
90     int findDeviceString(DeviceString *);
91
92     void pruneDuplicates();
93
94     typedef std::vector< DeviceString* > DeviceStringVector;
95     typedef std::vector< DeviceString* >::iterator DeviceStringVectorIterator;
96     DeviceStringVector m_DeviceStrings;
97
98 protected:
99     DECLARE_DEBUG_MODULE;
100
101 };
102
103 #endif /* __FFADO_DEVICESTRINGPARSER__ */
104
105
Note: See TracBrowser for help on using the browser.