root/trunk/libffado/src/libcontrol/Element.h

Revision 661, 3.1 kB (checked in by ppalmers, 13 years ago)

- Implement more complete mixer support for the saffire pro
- fix some cleanup issues with control elements

Line 
1 /*
2  * Copyright (C) 2007 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 library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License version 2.1, as published by the Free Software Foundation;
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
21  * MA 02110-1301 USA
22  */
23
24 #ifndef CONTROL_ELEMENT_H
25 #define CONTROL_ELEMENT_H
26
27 #include "debugmodule/debugmodule.h"
28
29 #include <vector>
30 #include <string>
31
32 namespace Control {
33
34 /*!
35 @brief Base class for control elements
36
37  This class should be subclassed to implement ffado control elements.
38 */
39 class Element
40 {
41 public:
42     Element();
43     Element(std::string n);
44     virtual ~Element() {};
45
46     virtual std::string getName() {return m_Name;};
47     virtual bool setName( std::string n )
48         { m_Name=n; return true;};
49
50     virtual std::string getLabel() {return m_Label;};
51     virtual bool setLabel( std::string n )
52         { m_Label=n; return true;};
53
54     virtual std::string getDescription() {return m_Description;};
55     virtual bool setDescription( std::string n )
56         { m_Description=n; return true;};
57
58     uint64_t getId()
59         {return m_id;};
60    
61     virtual void show();
62
63     /**
64      * set verbosity level
65      */
66     virtual void setVerboseLevel(int l);
67
68 private:
69     std::string m_Name;
70     std::string m_Label;
71     std::string m_Description;
72    
73     uint64_t m_id;
74
75 protected:
76     DECLARE_DEBUG_MODULE;
77
78 };
79 typedef std::vector<Element *> ElementVector;
80 typedef std::vector<Element *>::iterator ElementVectorIterator;
81 typedef std::vector<Element *>::const_iterator ConstElementVectorIterator;
82
83 /*!
84 @brief Base class for control containers
85
86  This class should be subclassed to implement ffado control container elements.
87  Containers are classes that can hold a set of control elements. They themselves
88  are control elements such that hierarchies can be defined using them.
89  
90  Special control containers that act on all of their children can also be
91  implemented.
92 */
93 class Container : public Element
94 {
95 public:
96     Container();
97     Container(std::string n);
98     virtual ~Container() {};
99    
100     virtual bool addElement(Element *e);
101     virtual bool deleteElement(Element *e);
102     virtual bool clearElements()
103         {return clearElements(false);};
104     virtual bool clearElements(bool delete_pointers);
105
106     unsigned int countElements()
107         {return m_Children.size();};
108
109     const ElementVector & getElements()
110         {return m_Children;};
111
112     virtual void show();
113     virtual void setVerboseLevel(int l);
114
115 protected:
116     ElementVector m_Children;
117 };
118
119
120 }; // namespace Control
121
122 #endif // CONTROL_ELEMENT_H
Note: See TracBrowser for help on using the browser.