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

Revision 575, 2.6 kB (checked in by ppalmers, 15 years ago)

- Fixed bug in dbus c++ bindings
- First attempt at a decoupled control interface. [WIP]


The src/libcontrol/* elements are the ones that should be
subclassed to implement control elements on the FFADODevice
side.

The tests/controlserver.* files contain some code that
interfaces the DBus calls to these libcontrol elements. The
DBus classes allow for introspection and path discovery,
such that we don't have to care about that anymore.

In the end it should be fairly easy to write another 'backend'
to replace the current DBus one, e.g. to implement OSC support
or MIDI support. (Should we ever want that)

Note that there is no connection between ffado and dbus yet,
this code is merely to experiment with the Control/DBus infra-
structure. Once that is sort-of working, connecting ffado to
this infrastructure is a matter of subclassing the Control::*
classes, creating them on discovery and putting them into one
Container::* that is passed on to the DBus handlers.

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     uint64_t getId()
51         {return m_id;};
52    
53     virtual void show();
54
55     /**
56      * set verbosity level
57      */
58     virtual void setVerboseLevel(int l);
59
60 private:
61     std::string m_Name;
62     uint64_t m_id;
63
64 protected:
65     DECLARE_DEBUG_MODULE;
66
67 };
68 typedef std::vector<Element *> ElementVector;
69 typedef std::vector<Element *>::iterator ElementVectorIterator;
70 typedef std::vector<Element *>::const_iterator ConstElementVectorIterator;
71
72 /*!
73 @brief Base class for control containers
74
75  This class should be subclassed to implement ffado control container elements.
76  Containers are classes that can hold a set of control elements. They themselves
77  are control elements such that hierarchies can be defined using them.
78  
79  Special control containers that act on all of their children can also be
80  implemented.
81 */
82 class Container : public Element
83 {
84 public:
85     Container();
86     Container(std::string n);
87     virtual ~Container() {};
88    
89     virtual bool addElement(Element *e);
90     virtual bool deleteElement(Element *e);
91     virtual bool clear()
92         {m_Children.clear(); return true;};
93
94     unsigned int countElements()
95         {return m_Children.size();};
96
97     const ElementVector & getElements()
98         {return m_Children;};
99
100     virtual void show();
101 protected:
102     ElementVector m_Children;
103 };
104
105
106 }; // namespace Control
107
108 #endif // CONTROL_ELEMENT_H
Note: See TracBrowser for help on using the browser.