root/trunk/libfreebob/src/libfreebobavc/avc_extended_cmd_generic.cpp

Revision 172, 15.1 kB (checked in by wagi, 18 years ago)

2006-03-10 Daniel Wagner <wagi@monom.org>

  • src/libfreebobavc/Makefile.am: New files added.
  • src/libfreebobavc/avc_extended_subunit_info.cpp: Likewise.
  • src/libfreebobavc/avc_extended_subunit_info.h: Likewise
  • src/libfreebobavc/avc_definitions.h: Several small improvements.
  • src/libfreebobavc/avc_extended_cmd_generic.cpp: Likewise.
  • src/libfreebobavc/avc_extended_cmd_generic.h: Likewise.
  • src/libfreebobavc/avc_extended_plug_info.cpp: Likewise.
  • src/libfreebobavc/avc_generic.cpp: Likewise.
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1 /* avc_extended_cmd_generic.cpp
2  * Copyright (C) 2005 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 #include "avc_extended_cmd_generic.h"
22 #include "serialize.h"
23 #include "ieee1394service.h"
24
25 UnitPlugAddress::UnitPlugAddress( EPlugType plugType,  plug_type_t plugId )
26     : m_plugType( plugType )
27     , m_plugId( plugId )
28     , m_reserved( 0xff )
29 {
30 }
31
32 UnitPlugAddress::~UnitPlugAddress()
33 {
34 }
35
36 bool
37 UnitPlugAddress::serialize( IOSSerialize& se )
38 {
39     se.write( m_plugType, "UnitPlugAddress plugType" );
40     se.write( m_plugId, "UnitPlugAddress plugId" );
41     se.write( m_reserved, "UnitPlugAddress reserved" );
42     return true;
43 }
44
45 bool
46 UnitPlugAddress::deserialize( IISDeserialize& de )
47 {
48     de.read( &m_plugType );
49     de.read( &m_plugId );
50     de.read( &m_reserved );
51     return true;
52 }
53
54 UnitPlugAddress*
55 UnitPlugAddress::clone() const
56 {
57     return new UnitPlugAddress( *this );
58 }
59
60 ////////////////////////////////////////////////////////////
61
62 SubunitPlugAddress::SubunitPlugAddress( plug_id_t plugId )
63     : m_plugId( plugId )
64     , m_reserved0( 0xff )
65     , m_reserved1( 0xff )
66 {
67 }
68
69 SubunitPlugAddress::~SubunitPlugAddress()
70 {
71 }
72
73 bool
74 SubunitPlugAddress::serialize( IOSSerialize& se )
75 {
76     se.write( m_plugId, "SubunitPlugAddress plugId" );
77     se.write( m_reserved0, "SubunitPlugAddress reserved0" );
78     se.write( m_reserved1, "SubunitPlugAddress reserved1" );
79     return true;
80 }
81
82 bool
83 SubunitPlugAddress::deserialize( IISDeserialize& de )
84 {
85     de.read( &m_plugId );
86     de.read( &m_reserved0 );
87     de.read( &m_reserved1 );
88     return true;
89 }
90
91 SubunitPlugAddress*
92 SubunitPlugAddress::clone() const
93 {
94     return new SubunitPlugAddress( *this );
95 }
96
97 ////////////////////////////////////////////////////////////
98
99 FunctionBlockPlugAddress::FunctionBlockPlugAddress(  function_block_type_t functionBlockType,
100                                                      function_block_id_t functionBlockId,
101                                                      plug_id_t plugId )
102     : m_functionBlockType( functionBlockType )
103     , m_functionBlockId( functionBlockId )
104     , m_plugId( plugId )
105 {
106 }
107
108 FunctionBlockPlugAddress::~FunctionBlockPlugAddress()
109 {
110 }
111
112 bool
113 FunctionBlockPlugAddress::serialize( IOSSerialize& se )
114 {
115     se.write( m_functionBlockType, "FunctionBlockPlugAddress functionBlockType" );
116     se.write( m_functionBlockId, "FunctionBlockPlugAddress functionBlockId" );
117     se.write( m_plugId, "FunctionBlockPlugAddress plugId" );
118     return true;
119 }
120
121 bool
122 FunctionBlockPlugAddress::deserialize( IISDeserialize& de )
123 {
124     de.read( &m_functionBlockType );
125     de.read( &m_functionBlockId );
126     de.read( &m_plugId );
127     return true;
128 }
129
130 FunctionBlockPlugAddress*
131 FunctionBlockPlugAddress:: clone() const
132 {
133     return new FunctionBlockPlugAddress( *this );
134 }
135
136 ////////////////////////////////////////////////////////////
137
138 UndefinedPlugAddress::UndefinedPlugAddress()
139     : m_reserved0( 0xff )
140     , m_reserved1( 0xff )
141     , m_reserved2( 0xff )
142 {
143 }
144
145 UndefinedPlugAddress::~UndefinedPlugAddress()
146 {
147 }
148
149 bool
150 UndefinedPlugAddress::serialize( IOSSerialize& se )
151 {
152     se.write( m_reserved0, "UndefinedPlugAddress reserved0" );
153     se.write( m_reserved1, "UndefinedPlugAddress reserved1" );
154     se.write( m_reserved2, "UndefinedPlugAddress reserved2" );
155     return true;
156 }
157
158 bool
159 UndefinedPlugAddress::deserialize( IISDeserialize& de )
160 {
161     de.read( &m_reserved0 );
162     de.read( &m_reserved1 );
163     de.read( &m_reserved2 );
164     return true;
165 }
166
167 UndefinedPlugAddress*
168 UndefinedPlugAddress:: clone() const
169 {
170     return new UndefinedPlugAddress( *this );
171 }
172
173 ////////////////////////////////////////////////////////////
174 ////////////////////////////////////////////////////////////
175
176 UnitPlugSpecificDataPlugAddress::UnitPlugSpecificDataPlugAddress( EPlugType plugType,  plug_type_t plugId )
177     : m_plugType( plugType )
178     , m_plugId( plugId )
179     , m_reserved0( 0xff )
180     , m_reserved1( 0xff )
181     , m_reserved2( 0xff )
182 {
183 }
184
185 UnitPlugSpecificDataPlugAddress::~UnitPlugSpecificDataPlugAddress()
186 {
187 }
188
189 bool
190 UnitPlugSpecificDataPlugAddress::serialize( IOSSerialize& se )
191 {
192     se.write( m_plugType,  "UnitPlugSpecificDataPlugAddress plugType" );
193     se.write( m_plugId,    "UnitPlugSpecificDataPlugAddress plugId" );
194     se.write( m_reserved0, "UnitPlugSpecificDataPlugAddress reserved0" );
195     se.write( m_reserved1, "UnitPlugSpecificDataPlugAddress reserved1" );
196     se.write( m_reserved2, "UnitPlugSpecificDataPlugAddress reserved2" );
197     return true;
198 }
199
200 bool
201 UnitPlugSpecificDataPlugAddress::deserialize( IISDeserialize& de )
202 {
203     de.read( &m_plugType );
204     de.read( &m_plugId );
205     de.read( &m_reserved0 );
206     de.read( &m_reserved1 );
207     de.read( &m_reserved2 );
208     return true;
209 }
210
211 UnitPlugSpecificDataPlugAddress*
212 UnitPlugSpecificDataPlugAddress::clone() const
213 {
214     return new UnitPlugSpecificDataPlugAddress( *this );
215 }
216
217 ////////////////////////////////////////////////////////////
218
219 SubunitPlugSpecificDataPlugAddress::SubunitPlugSpecificDataPlugAddress(
220     AVCCommand::ESubunitType subunitType,
221     subunit_id_t subunitId,
222     plug_id_t plugId )
223     : m_subunitType( subunitType )
224     , m_subunitId( subunitId )
225     , m_plugId( plugId )
226     , m_reserved0( 0xff )
227     , m_reserved1( 0xff )
228 {
229 }
230
231 SubunitPlugSpecificDataPlugAddress::~SubunitPlugSpecificDataPlugAddress()
232 {
233 }
234
235 bool
236 SubunitPlugSpecificDataPlugAddress::serialize( IOSSerialize& se )
237 {
238     se.write( m_subunitType,  "SubunitPlugSpecificDataPlugAddress subunitType" );
239     se.write( m_subunitId,    "SubunitPlugSpecificDataPlugAddress subunitId" );
240     se.write( m_plugId,       "SubunitPlugSpecificDataPlugAddress plugId" );
241     se.write( m_reserved0,    "SubunitPlugSpecificDataPlugAddress reserved0" );
242     se.write( m_reserved1,    "SubunitPlugSpecificDataPlugAddress reserved1" );
243     return true;
244 }
245
246 bool
247 SubunitPlugSpecificDataPlugAddress::deserialize( IISDeserialize& de )
248 {
249     de.read( &m_subunitType );
250     de.read( &m_subunitId );
251     de.read( &m_plugId );
252     de.read( &m_reserved0 );
253     de.read( &m_reserved1 );
254     return true;
255 }
256
257 SubunitPlugSpecificDataPlugAddress*
258 SubunitPlugSpecificDataPlugAddress::clone() const
259 {
260     return new SubunitPlugSpecificDataPlugAddress( *this );
261 }
262
263 ////////////////////////////////////////////////////////////
264
265 FunctionBlockPlugSpecificDataPlugAddress::FunctionBlockPlugSpecificDataPlugAddress(
266     AVCCommand::ESubunitType subunitType,
267     subunit_id_t subunitId,
268     function_block_type_t functionBlockType,
269     function_block_id_t functionBlockId,
270     plug_id_t plugId )
271     : m_subunitType( subunitType )
272     , m_subunitId( subunitId )
273     , m_functionBlockType( functionBlockType )
274     , m_functionBlockId( functionBlockId )
275     , m_plugId( plugId )
276 {
277 }
278
279 FunctionBlockPlugSpecificDataPlugAddress::~FunctionBlockPlugSpecificDataPlugAddress()
280 {
281 }
282
283 bool
284 FunctionBlockPlugSpecificDataPlugAddress::serialize( IOSSerialize& se )
285 {
286     se.write( m_subunitType,       "FunctionPlugSpecificDataBlockPlugAddress subunitType" );
287     se.write( m_subunitId,         "FunctionPlugSpecificDataBlockPlugAddress subunitId" );
288     se.write( m_functionBlockType, "FunctionBlockPlugSpecificDataPlugAddress functionBlockType" );
289     se.write( m_functionBlockId,   "FunctionBlockPlugSpecificDataPlugAddress functionBlockId" );
290     se.write( m_plugId,            "FunctionBlockPlugSpecificDataPlugAddress plugId" );
291     return true;
292 }
293
294 bool
295 FunctionBlockPlugSpecificDataPlugAddress::deserialize( IISDeserialize& de )
296 {
297     de.read( &m_subunitType );
298     de.read( &m_subunitId );
299     de.read( &m_functionBlockType );
300     de.read( &m_functionBlockId );
301     de.read( &m_plugId );
302     return true;
303 }
304
305 FunctionBlockPlugSpecificDataPlugAddress*
306 FunctionBlockPlugSpecificDataPlugAddress:: clone() const
307 {
308     return new FunctionBlockPlugSpecificDataPlugAddress( *this );
309 }
310
311 ////////////////////////////////////////////////////////////
312
313 UndefinedPlugSpecificDataPlugAddress::UndefinedPlugSpecificDataPlugAddress()
314     : m_reserved0( 0xff )
315     , m_reserved1( 0xff )
316     , m_reserved2( 0xff )
317     , m_reserved3( 0xff )
318     , m_reserved4( 0xff )
319 {
320 }
321
322 UndefinedPlugSpecificDataPlugAddress::~UndefinedPlugSpecificDataPlugAddress()
323 {
324 }
325
326 bool
327 UndefinedPlugSpecificDataPlugAddress::serialize( IOSSerialize& se )
328 {
329     se.write( m_reserved0, "UndefinedPlugAddress reserved0" );
330     se.write( m_reserved1, "UndefinedPlugAddress reserved1" );
331     se.write( m_reserved2, "UndefinedPlugAddress reserved2" );
332     se.write( m_reserved3, "UndefinedPlugAddress reserved3" );
333     se.write( m_reserved4, "UndefinedPlugAddress reserved4" );
334     return true;
335 }
336
337 bool
338 UndefinedPlugSpecificDataPlugAddress::deserialize( IISDeserialize& de )
339 {
340     de.read( &m_reserved0 );
341     de.read( &m_reserved1 );
342     de.read( &m_reserved2 );
343     de.read( &m_reserved3 );
344     de.read( &m_reserved4 );
345     return true;
346 }
347
348 UndefinedPlugSpecificDataPlugAddress*
349 UndefinedPlugSpecificDataPlugAddress:: clone() const
350 {
351     return new UndefinedPlugSpecificDataPlugAddress( *this );
352 }
353
354 ////////////////////////////////////////////////////////////
355 ////////////////////////////////////////////////////////////
356
357 PlugAddress::PlugAddress( EPlugDirection plugDirection,
358                           EPlugAddressMode plugAddressMode,
359                           UnitPlugAddress& unitPlugAddress )
360     : m_plugDirection( plugDirection )
361     , m_addressMode( plugAddressMode )
362     , m_plugAddressData( new UnitPlugAddress( unitPlugAddress ) )
363 {
364 }
365
366 PlugAddress::PlugAddress( EPlugDirection plugDirection,
367                           EPlugAddressMode plugAddressMode,
368                           SubunitPlugAddress& subUnitPlugAddress )
369     : m_plugDirection( plugDirection )
370     , m_addressMode( plugAddressMode )
371     , m_plugAddressData( new SubunitPlugAddress( subUnitPlugAddress ) )
372 {
373 }
374
375 PlugAddress::PlugAddress( EPlugDirection plugDirection,
376                           EPlugAddressMode plugAddressMode,
377                           FunctionBlockPlugAddress& functionBlockPlugAddress )
378     : m_plugDirection( plugDirection )
379     , m_addressMode( plugAddressMode )
380     , m_plugAddressData( new FunctionBlockPlugAddress( functionBlockPlugAddress ) )
381 {
382 }
383
384 PlugAddress::PlugAddress()
385     : m_plugDirection( ePD_Undefined )
386     , m_addressMode( ePAM_Undefined )
387     , m_plugAddressData( new UndefinedPlugAddress() )
388 {
389 }
390
391 PlugAddress::PlugAddress( const PlugAddress& pa )
392     : m_plugDirection( pa.m_plugDirection )
393     , m_addressMode( pa.m_addressMode )
394     , m_plugAddressData( dynamic_cast<PlugAddressData*>( pa.m_plugAddressData->clone() ) )
395 {
396 }
397
398 PlugAddress::~PlugAddress()
399 {
400     delete m_plugAddressData;
401     m_plugAddressData = 0;
402 }
403
404 bool
405 PlugAddress::serialize( IOSSerialize& se )
406 {
407     se.write( m_plugDirection, "PlugAddress plugDirection" );
408     se.write( m_addressMode, "PlugAddress addressMode" );
409     return m_plugAddressData->serialize( se );
410 }
411
412 bool
413 PlugAddress::deserialize( IISDeserialize& de )
414 {
415     de.read( &m_plugDirection );
416     de.read( &m_addressMode );
417     return m_plugAddressData->deserialize( de );
418 }
419
420 PlugAddress*
421 PlugAddress::clone() const
422 {
423     return new PlugAddress( *this );
424 }
425
426 const char* plugAddressDirectionStrings[] =
427 {
428     "Input",
429     "Output",
430     "Undefined",
431 };
432
433 const char* plugAddressAddressModeStrings[] =
434 {
435     "Unit",
436     "Subunit",
437     "FunctionBlock",
438     "Undefined",
439 };
440
441 const char*
442 plugAddressPlugDirectionToString( PlugAddress::EPlugDirection direction  )
443 {
444     if ( direction > PlugAddress::ePD_Output ) {
445         direction = PlugAddress::ePD_Undefined;
446     }
447     return plugAddressDirectionStrings[direction];
448 }
449
450 const char*
451 plugAddressAddressModeToString( PlugAddress::EPlugAddressMode mode )
452 {
453     if ( mode > PlugAddress::ePAM_FunctionBlock ) {
454         mode = PlugAddress::ePAM_FunctionBlock;
455     }
456     return plugAddressAddressModeStrings[mode];
457 }
458
459
460 ////////////////////////////////////////////////////////////
461
462 PlugAddressSpecificData::PlugAddressSpecificData( EPlugDirection plugDirection,
463                                                   EPlugAddressMode plugAddressMode,
464                                                   UnitPlugSpecificDataPlugAddress& unitPlugAddress )
465     : m_plugDirection( plugDirection )
466     , m_addressMode( plugAddressMode )
467     , m_plugAddressData( new UnitPlugSpecificDataPlugAddress( unitPlugAddress ) )
468 {
469 }
470
471 PlugAddressSpecificData::PlugAddressSpecificData( EPlugDirection plugDirection,
472                                                   EPlugAddressMode plugAddressMode,
473                                                   SubunitPlugSpecificDataPlugAddress& subUnitPlugAddress )
474     : m_plugDirection( plugDirection )
475     , m_addressMode( plugAddressMode )
476     , m_plugAddressData( new SubunitPlugSpecificDataPlugAddress( subUnitPlugAddress ) )
477 {
478 }
479
480 PlugAddressSpecificData::PlugAddressSpecificData( EPlugDirection plugDirection,
481                                                   EPlugAddressMode plugAddressMode,
482                                                   FunctionBlockPlugSpecificDataPlugAddress& functionBlockPlugAddress )
483     : m_plugDirection( plugDirection )
484     , m_addressMode( plugAddressMode )
485     , m_plugAddressData( new FunctionBlockPlugSpecificDataPlugAddress( functionBlockPlugAddress ) )
486 {
487 }
488
489 PlugAddressSpecificData::PlugAddressSpecificData( const PlugAddressSpecificData& pa )
490     : m_plugDirection( pa.m_plugDirection )
491     , m_addressMode( pa.m_addressMode )
492     , m_plugAddressData( dynamic_cast<PlugAddressData*>( pa.m_plugAddressData->clone() ) )
493 {
494 }
495
496 PlugAddressSpecificData::~PlugAddressSpecificData()
497 {
498     delete m_plugAddressData;
499     m_plugAddressData = 0;
500 }
501
502 bool
503 PlugAddressSpecificData::serialize( IOSSerialize& se )
504 {
505     se.write( m_plugDirection, "PlugAddressSpecificData plugDirection" );
506     se.write( m_addressMode, "PlugAddressSpecificData addressMode" );
507     return m_plugAddressData->serialize( se );
508 }
509
510 bool
511 PlugAddressSpecificData::deserialize( IISDeserialize& de )
512 {
513     de.read( &m_plugDirection );
514     de.read( &m_addressMode );
515     if ( m_plugAddressData ) {
516         delete m_plugAddressData;
517         m_plugAddressData = 0;
518     }
519     switch ( m_addressMode ) {
520     case ePAM_Unit:
521         m_plugAddressData =
522             new UnitPlugSpecificDataPlugAddress(
523                 UnitPlugSpecificDataPlugAddress::ePT_PCR,
524                 0xff );
525         break;
526     case ePAM_Subunit:
527         m_plugAddressData =
528             new SubunitPlugSpecificDataPlugAddress(
529                 AVCCommand::eST_Reserved,
530                 0xff,
531                 0xff );
532         break;
533     case ePAM_FunctionBlock:
534         m_plugAddressData =
535             new FunctionBlockPlugSpecificDataPlugAddress(
536                 AVCCommand::eST_Reserved,
537                 0xff,
538                 0xff,
539                 0xff,
540                 0xff);
541         break;
542     default:
543         m_plugAddressData =
544             new UndefinedPlugSpecificDataPlugAddress();
545     }
546
547     return m_plugAddressData->deserialize( de );
548 }
549
550 PlugAddressSpecificData*
551 PlugAddressSpecificData::clone() const
552 {
553     return new PlugAddressSpecificData( *this );
554 }
555
556
Note: See TracBrowser for help on using the browser.