root/trunk/libffado/src/DeviceStringParser.h

Revision 1568, 2.5 kB (checked in by holin, 15 years ago)

gcc 4.4 fixes (r1566, r1567, DICE) to trunk

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 #include <stdint.h>
32
33 class ConfigRom;
34
35 class DeviceStringParser {
36
37 protected:
38     class DeviceString {
39     public:
40         enum eType {
41             eInvalid = 0,
42             eBusNode = 1, // old-style hw:bus,node
43             eGUID = 2,    // GUID match
44         };
45
46         DeviceString(DeviceStringParser&);
47         ~DeviceString();
48
49         bool parse(std::string s);
50         bool match(ConfigRom &);
51
52         std::string getString() {return m_String;};
53         void show();
54
55         bool operator==(const DeviceString& x);
56         static bool isValidString(std::string s);
57
58     private:
59         DeviceStringParser & m_Parent;
60
61         int m_node;
62         int m_port;
63         uint64_t m_guid;
64         std::string m_String;
65         enum eType  m_Type;
66
67         DECLARE_DEBUG_MODULE_REFERENCE;
68     };
69
70 public:
71     DeviceStringParser();
72     virtual ~DeviceStringParser();
73
74     int countDeviceStrings() {return m_DeviceStrings.size();};
75
76     bool match(ConfigRom &);
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.