Changeset 371

Show
Ignore:
Timestamp:
01/06/07 04:45:31 (17 years ago)
Author:
wagi
Message:

AvDevice::serialize: m_pcrPlugs and m_externalPlug added to the bed processed
(ongoing)
AvDevice::deserialize: likewise
AvPlug?: started with de/serializing functions (ongoing)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/libfreebob/src/bebob/bebob_avdevice.cpp

    r370 r371  
    12291229} 
    12301230 
     1231 
     1232template <typename T> bool serializeVector( Glib::ustring path, 
     1233                                            Util::IOSerialize& ser, 
     1234                                            T& vec ) 
     1235{ 
     1236    bool result = true; // if vec.size() == 0 
     1237    int i = 0; 
     1238    for ( typename T::iterator it = vec.begin(); it != vec.end(); ++it ) { 
     1239        std::ostringstream strstrm; 
     1240        strstrm << path << i; 
     1241        result &= ( *it )->serialize( strstrm.str() + "/", ser ); 
     1242        i++; 
     1243    } 
     1244    return result; 
     1245} 
     1246 
     1247template <typename T, typename VT> bool deserializeVector( Glib::ustring path, 
     1248                                                           Util::IODeserialize& deser, 
     1249                                                           Ieee1394Service& ieee1394Service, 
     1250                                                           ConfigRom& configRom, 
     1251                                                           AvPlugManager& plugManager, 
     1252                                                           VT& vec ) 
     1253{ 
     1254    int i = 0; 
     1255    bool bFinished = false; 
     1256    do { 
     1257        std::ostringstream strstrm; 
     1258        strstrm << path << i; 
     1259        T* ptr = T::deserialize( strstrm.str() + "/", 
     1260                                 deser, 
     1261                                 ieee1394Service, 
     1262                                 configRom, 
     1263                                 plugManager ); 
     1264        if ( ptr ) { 
     1265            vec.push_back( ptr ); 
     1266            i++; 
     1267        } else { 
     1268            bFinished = true; 
     1269        } 
     1270    } while ( !bFinished ); 
     1271 
     1272    return true; 
     1273} 
     1274 
    12311275bool 
    12321276AvDevice::serialize( Glib::ustring basePath, Util::IOSerialize& ser ) 
    12331277{ 
    12341278    bool result; 
    1235     result = m_pConfigRom->serialize( basePath + "m_pConfigRom/", ser ); 
     1279    result  = m_pConfigRom->serialize( basePath + "m_pConfigRom/", ser ); 
     1280    result &= ser.write( basePath + "m_verboseLevel", m_verboseLevel ); 
     1281 
     1282    result &= serializeVector( basePath + "PCRPlug", ser, m_pcrPlugs ); 
     1283    result &= serializeVector( basePath + "ExternelPlug", ser, m_externalPlugs ); 
     1284 
     1285    // XXX ... 
    12361286 
    12371287    return result; 
    12381288} 
     1289 
    12391290 
    12401291AvDevice* 
     
    12551306 
    12561307        pDev->m_1394Service = &ieee1394Service; 
    1257  
     1308        bool result; 
     1309        result = deser.read( basePath + "m_verboseLevel", pDev->m_verboseLevel ); 
     1310 
     1311        result &= deserializeVector<AvPlug>( basePath + "PCRPlug", deser, ieee1394Service, *pDev->m_pConfigRom.get(), pDev->m_plugManager, pDev->m_pcrPlugs ); 
     1312        result &= deserializeVector<AvPlug>( basePath + "ExternalPlug", deser, ieee1394Service, *pDev->m_pConfigRom.get(), pDev->m_plugManager, pDev->m_externalPlugs ); 
     1313 
     1314        // XXX ... 
    12581315    } 
    12591316 
  • trunk/libfreebob/src/bebob/bebob_avdevice.h

    r370 r371  
    11/* bebob_avdevice.h 
    2  * Copyright (C) 2005,06 by Daniel Wagner 
     2 * Copyright (C) 2005,06,07 by Daniel Wagner 
    33 * 
    44 * This file is part of FreeBoB. 
  • trunk/libfreebob/src/bebob/bebob_avplug.cpp

    r370 r371  
    9595        setDebugLevel( DEBUG_LEVEL_VERBOSE ); 
    9696     } 
     97} 
     98 
     99AvPlug::AvPlug() 
     100    : m_1394Service( 0 ) 
     101    , m_pConfigRom( 0 ) 
     102    , m_subunitType( AVCCommand::eST_Reserved ) // a good value for unknown/undefined? 
     103    , m_subunitId( 0 ) 
     104    , m_functionBlockType( 0 ) 
     105    , m_functionBlockId( 0 ) 
     106    , m_addressType( eAPA_Undefined ) 
     107    , m_direction( eAPD_Unknown ) 
     108    , m_id( 0 ) 
     109    , m_infoPlugType( eAPT_Unknown ) 
     110    , m_nrOfChannels( 0 ) 
     111    , m_plugManager( 0 ) 
     112    , m_verboseLevel( 0 ) 
     113    , m_globalId( 0 ) 
     114{ 
    97115} 
    98116 
     
    14131431} 
    14141432 
     1433bool 
     1434AvPlug::serialize( Glib::ustring basePath, Util::IOSerialize& ser ) 
     1435{ 
     1436    bool result; 
     1437    result  = ser.write( basePath + "m_subunitType", m_subunitType ); 
     1438    result &= ser.write( basePath + "m_subunitId", m_subunitId ); 
     1439    /// XXX ... 
     1440 
     1441    return result; 
     1442} 
     1443 
     1444AvPlug* 
     1445AvPlug::deserialize( Glib::ustring basePath, 
     1446                     Util::IODeserialize& deser, 
     1447                     Ieee1394Service& ieee1394Service, 
     1448                     ConfigRom& configRom, 
     1449                     AvPlugManager& plugManager ) 
     1450{ 
     1451    AvPlug* pPlug = new AvPlug; 
     1452    if ( !pPlug ) { 
     1453        return 0; 
     1454    } 
     1455 
     1456    pPlug->m_1394Service = &ieee1394Service; 
     1457    pPlug->m_pConfigRom = &configRom; 
     1458    pPlug->m_plugManager = &plugManager; 
     1459    bool result; 
     1460    result  = deser.read( basePath + "m_subunitType", pPlug->m_subunitType ); 
     1461    result &= deser.read( basePath + "m_subunitId", pPlug->m_subunitId ); 
     1462    // XXX ... 
     1463 
     1464    if ( !result ) { 
     1465        delete pPlug; 
     1466        return 0; 
     1467    } 
     1468 
     1469    return pPlug; 
     1470} 
     1471 
    14151472///////////////////////////////////////// 
    14161473///////////////////////////////////////// 
  • trunk/libfreebob/src/bebob/bebob_avplug.h

    r370 r371  
    3030#include "libfreebob/xmlparser.h" 
    3131 
     32#include "libutil/serialize.h" 
     33 
    3234#include "debugmodule/debugmodule.h" 
     35 
     36#include <glibmm/ustring.h> 
    3337 
    3438class Ieee1394Service; 
     
    155159    { return m_clusterInfos; } 
    156160 
     161    bool serialize( Glib::ustring basePath, Util::IOSerialize& ser ); 
     162    static AvPlug* deserialize( Glib::ustring basePath, 
     163                                Util::IODeserialize& deser, 
     164                                Ieee1394Service& ieee1394Service, 
     165                                ConfigRom& configRom, 
     166                                AvPlugManager& plugManager ); 
    157167protected: 
    158168    bool discoverPlugType(); 
     
    195205 
    196206    EAvPlugDirection toggleDirection( EAvPlugDirection direction ) const; 
     207 
     208private: 
     209    AvPlug(); 
    197210 
    198211private: