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 CONTROL_BASICELEMENTS_H |
---|
25 |
#define CONTROL_BASICELEMENTS_H |
---|
26 |
|
---|
27 |
#include "debugmodule/debugmodule.h" |
---|
28 |
|
---|
29 |
#include <vector> |
---|
30 |
#include <string> |
---|
31 |
|
---|
32 |
#include "Element.h" |
---|
33 |
|
---|
34 |
namespace Control { |
---|
35 |
|
---|
36 |
/*! |
---|
37 |
@brief Base class for contignous control elements |
---|
38 |
*/ |
---|
39 |
class Continuous |
---|
40 |
: public Element |
---|
41 |
{ |
---|
42 |
public: |
---|
43 |
Continuous(Element *p) : Element(p) {}; |
---|
44 |
Continuous(Element *p, std::string n) : Element(p, n) {}; |
---|
45 |
virtual ~Continuous() {}; |
---|
46 |
|
---|
47 |
virtual bool setValue(double v) = 0; |
---|
48 |
virtual double getValue() = 0; |
---|
49 |
virtual bool setValue(int idx, double v) = 0; |
---|
50 |
virtual double getValue(int idx) = 0; |
---|
51 |
|
---|
52 |
virtual double getMinimum() = 0; |
---|
53 |
virtual double getMaximum() = 0; |
---|
54 |
}; |
---|
55 |
|
---|
56 |
/*! |
---|
57 |
@brief Base class for discrete control elements |
---|
58 |
*/ |
---|
59 |
class Discrete |
---|
60 |
: public Element |
---|
61 |
{ |
---|
62 |
public: |
---|
63 |
Discrete(Element *p) : Element(p) {}; |
---|
64 |
Discrete(Element *p, std::string n) : Element(p, n) {}; |
---|
65 |
virtual ~Discrete() {}; |
---|
66 |
|
---|
67 |
virtual bool setValue(int v) = 0; |
---|
68 |
virtual int getValue() = 0; |
---|
69 |
virtual bool setValue(int idx, int v) = 0; |
---|
70 |
virtual int getValue(int idx) = 0; |
---|
71 |
|
---|
72 |
virtual int getMinimum() = 0; |
---|
73 |
virtual int getMaximum() = 0; |
---|
74 |
|
---|
75 |
}; |
---|
76 |
|
---|
77 |
/*! |
---|
78 |
@brief Base class for textual control elements |
---|
79 |
*/ |
---|
80 |
class Text |
---|
81 |
: public Element |
---|
82 |
{ |
---|
83 |
public: |
---|
84 |
Text(Element *p) : Element(p) {}; |
---|
85 |
Text(Element *p, std::string n) : Element(p, n) {}; |
---|
86 |
virtual ~Text() {}; |
---|
87 |
|
---|
88 |
virtual bool setValue(std::string v) = 0; |
---|
89 |
virtual std::string getValue() = 0; |
---|
90 |
}; |
---|
91 |
|
---|
92 |
/*! |
---|
93 |
@brief Base class for register access control elements |
---|
94 |
*/ |
---|
95 |
class Register |
---|
96 |
: public Element |
---|
97 |
{ |
---|
98 |
public: |
---|
99 |
Register(Element *p) : Element(p) {}; |
---|
100 |
Register(Element *p, std::string n) : Element(p, n) {}; |
---|
101 |
virtual ~Register() {}; |
---|
102 |
|
---|
103 |
virtual bool setValue(uint64_t addr, uint64_t value) = 0; |
---|
104 |
virtual uint64_t getValue(uint64_t addr) = 0; |
---|
105 |
}; |
---|
106 |
|
---|
107 |
/*! |
---|
108 |
@brief Base class for basic enumerated control elements |
---|
109 |
*/ |
---|
110 |
class Enum |
---|
111 |
: public Element |
---|
112 |
{ |
---|
113 |
public: |
---|
114 |
Enum(Element *p) : Element(p) {}; |
---|
115 |
Enum(Element *p, std::string n) : Element(p, n) {}; |
---|
116 |
virtual ~Enum() {}; |
---|
117 |
|
---|
118 |
virtual bool select(int idx) = 0; |
---|
119 |
virtual int selected() = 0; |
---|
120 |
virtual int count() = 0; |
---|
121 |
virtual std::string getEnumLabel(int idx) = 0; |
---|
122 |
}; |
---|
123 |
|
---|
124 |
/*! |
---|
125 |
@brief Base class for attribute enumerated control elements |
---|
126 |
|
---|
127 |
The idea of this is that one can have a set of config values |
---|
128 |
available for a certain enum choice. |
---|
129 |
|
---|
130 |
Example: for clock source selection: |
---|
131 |
idx Label signal locked available |
---|
132 |
0 WordClock 0 0 1 |
---|
133 |
1 S/PDIF 1 0 1 |
---|
134 |
... |
---|
135 |
|
---|
136 |
Attributes: |
---|
137 |
0 signal |
---|
138 |
1 locked |
---|
139 |
2 available |
---|
140 |
|
---|
141 |
*/ |
---|
142 |
class AttributeEnum |
---|
143 |
: public Enum |
---|
144 |
{ |
---|
145 |
public: |
---|
146 |
AttributeEnum(Element *p) : Enum(p) {}; |
---|
147 |
AttributeEnum(Element *p, std::string n) : Enum(p, n) {}; |
---|
148 |
virtual ~AttributeEnum() {}; |
---|
149 |
|
---|
150 |
virtual int attributeCount() = 0; |
---|
151 |
///> get a specific attribute value for the selected enum |
---|
152 |
virtual std::string getAttributeValue(int attridx) = 0; |
---|
153 |
///> get the name of the attribute with a certain index |
---|
154 |
virtual std::string getAttributeName(int attridx) = 0; |
---|
155 |
}; |
---|
156 |
|
---|
157 |
}; // namespace Control |
---|
158 |
|
---|
159 |
#endif // CONTROL_BASICELEMENTS_H |
---|