root/trunk/libfreebob/src/bebob/bebob_functionblock.h

Revision 378, 7.3 kB (checked in by wagi, 16 years ago)

FunctionBlock?: De/Serialize added

Line 
1 /* bebob_functionblock.h
2  * Copyright (C) 2006,07 by Daniel Wagner
3  *
4  * This file is part of FreeBoB.
5  *
6  * FreeBoB is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  * FreeBoB is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with FreeBoB; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
18  * MA 02111-1307 USA.
19  */
20
21 #ifndef BEBOB_FUNCTION_BLOCK_H
22 #define BEBOB_FUNCTION_BLOCK_H
23
24 #include "bebob/bebob_avplug.h"
25
26 #include "libfreebobavc/avc_definitions.h"
27 #include "debugmodule/debugmodule.h"
28
29 namespace BeBoB {
30
31 class AvDeviceSubunit;
32
33 class FunctionBlock {
34 public:
35     enum EFunctionBlockType {
36         eFBT_AllFunctinBlockType    = 0xff,
37         eFBT_AudioSubunitSelector   = 0x80,
38         eFBT_AudioSubunitFeature    = 0x81,
39         eFBT_AudioSubunitProcessing = 0x82,
40         eFBT_AudioSubunitCodec      = 0x83,
41     };
42
43     enum ESpecialPurpose {
44         eSP_InputGain,
45         eSP_OutputVolume,
46         eSP_NoSpecialPurpose
47     };
48
49     FunctionBlock( AvDeviceSubunit& subunit,
50                    function_block_type_t type,
51                    function_block_type_t subtype,
52                    function_block_id_t id,
53                    ESpecialPurpose purpose,
54                    no_of_input_plugs_t nrOfInputPlugs,
55                    no_of_output_plugs_t nrOfOutputPlugs,
56                    int verbose );
57     FunctionBlock( const FunctionBlock& rhs );
58     FunctionBlock();
59     virtual ~FunctionBlock();
60
61     virtual bool discover();
62     virtual bool discoverConnections();
63
64     virtual const char* getName() = 0;
65
66     bool serialize( Glib::ustring basePath, Util::IOSerialize& ser ) const;
67     static FunctionBlock* deserialize( Glib::ustring basePath,
68                                        Util::IODeserialize& deser,
69                                        AvDevice& avDevice,
70                                        AvDeviceSubunit& subunit);
71 protected:
72     bool discoverPlugs( AvPlug::EAvPlugDirection plugDirection,
73                         plug_id_t plugMaxId );
74
75 protected:
76     AvDeviceSubunit*      m_subunit;
77     function_block_type_t m_type;
78     function_block_type_t m_subtype;
79     function_block_id_t   m_id;
80     ESpecialPurpose       m_purpose;
81     no_of_input_plugs_t   m_nrOfInputPlugs;
82     no_of_output_plugs_t  m_nrOfOutputPlugs;
83     int                   m_verbose;
84     AvPlugVector          m_plugs;
85
86     DECLARE_DEBUG_MODULE;
87 };
88
89 typedef std::vector<FunctionBlock*> FunctionBlockVector;
90
91 /////////////////////////////////////
92 /////////////////////////////////////
93
94 class FunctionBlockSelector: public FunctionBlock
95 {
96 public:
97     FunctionBlockSelector(AvDeviceSubunit& subunit,
98                           function_block_id_t id,
99                           ESpecialPurpose purpose,
100                           no_of_input_plugs_t nrOfInputPlugs,
101                           no_of_output_plugs_t nrOfOutputPlugs,
102                           int verbose);
103     FunctionBlockSelector( const FunctionBlockSelector& rhs );
104     FunctionBlockSelector();
105     virtual ~FunctionBlockSelector();
106
107     virtual const char* getName();
108
109 protected:
110     virtual bool serializeChild( Glib::ustring basePath,
111                                  Util::IOSerialize& ser ) const;
112     virtual bool deserializeChild( Glib::ustring basePath,
113                                    Util::IODeserialize& deser,
114                                    AvDevice& avDevice );
115 };
116
117 /////////////////////////////////////
118
119 class FunctionBlockFeature: public FunctionBlock
120 {
121 public:
122     FunctionBlockFeature(AvDeviceSubunit& subunit,
123                          function_block_id_t id,
124                          ESpecialPurpose purpose,
125                          no_of_input_plugs_t nrOfInputPlugs,
126                          no_of_output_plugs_t nrOfOutputPlugs,
127                          int verbose);
128     FunctionBlockFeature( const FunctionBlockFeature& rhs );
129     FunctionBlockFeature();
130     virtual ~FunctionBlockFeature();
131
132     virtual const char* getName();
133
134 protected:
135     virtual bool serializeChild( Glib::ustring basePath,
136                                  Util::IOSerialize& ser ) const;
137     virtual bool deserializeChild( Glib::ustring basePath,
138                                    Util::IODeserialize& deser,
139                                    AvDevice& avDevice );
140 };
141
142 /////////////////////////////////////
143
144 class FunctionBlockEnhancedMixer: public FunctionBlock
145 {
146 public:
147     FunctionBlockEnhancedMixer( AvDeviceSubunit& subunit,
148                                 function_block_id_t id,
149                                 ESpecialPurpose purpose,
150                                 no_of_input_plugs_t nrOfInputPlugs,
151                                 no_of_output_plugs_t nrOfOutputPlugs,
152                                 int verbose );
153     FunctionBlockEnhancedMixer();
154     FunctionBlockEnhancedMixer( const FunctionBlockEnhancedMixer& rhs );
155     virtual ~FunctionBlockEnhancedMixer();
156
157     virtual const char* getName();
158
159 protected:
160     virtual bool serializeChild( Glib::ustring basePath,
161                                  Util::IOSerialize& ser ) const;
162     virtual bool deserializeChild( Glib::ustring basePath,
163                                    Util::IODeserialize& deser,
164                                    AvDevice& avDevice );
165 };
166
167 /////////////////////////////////////
168
169 class FunctionBlockProcessing: public FunctionBlock
170 {
171 public:
172     FunctionBlockProcessing( AvDeviceSubunit& subunit,
173                              function_block_id_t id,
174                              ESpecialPurpose purpose,
175                              no_of_input_plugs_t nrOfInputPlugs,
176                              no_of_output_plugs_t nrOfOutputPlugs,
177                              int verbose );
178     FunctionBlockProcessing( const FunctionBlockProcessing& rhs );
179     FunctionBlockProcessing();
180     virtual ~FunctionBlockProcessing();
181
182     virtual const char* getName();
183
184 protected:
185     virtual bool serializeChild( Glib::ustring basePath,
186                                  Util::IOSerialize& ser ) const;
187     virtual bool deserializeChild( Glib::ustring basePath,
188                                    Util::IODeserialize& deser,
189                                    AvDevice& avDevice );
190 };
191
192 /////////////////////////////////////
193
194 class FunctionBlockCodec: public FunctionBlock
195 {
196 public:
197     FunctionBlockCodec(AvDeviceSubunit& subunit,
198                        function_block_id_t id,
199                        ESpecialPurpose purpose,
200                        no_of_input_plugs_t nrOfInputPlugs,
201                        no_of_output_plugs_t nrOfOutputPlugs,
202                        int verbose);
203     FunctionBlockCodec( const FunctionBlockCodec& rhs );
204     FunctionBlockCodec();
205     virtual ~FunctionBlockCodec();
206
207     virtual const char* getName();
208
209 protected:
210     virtual bool serializeChild( Glib::ustring basePath,
211                                  Util::IOSerialize& ser ) const;
212     virtual bool deserializeChild( Glib::ustring basePath,
213                                    Util::IODeserialize& deser,
214                                    AvDevice& avDevice );
215 };
216
217 }
218
219 #endif
Note: See TracBrowser for help on using the browser.