Changeset 379

Show
Ignore:
Timestamp:
01/21/07 12:22:41 (17 years ago)
Author:
wagi
Message:

AvDevice?: all members are de/serialed now

Files:

Legend:

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

    r378 r379  
    12321232} 
    12331233 
     1234template <typename T> bool serializeVector( Glib::ustring path, 
     1235                                            Util::IOSerialize& ser, 
     1236                                            const T& vec ) 
     1237{ 
     1238    bool result = true; // if vec.size() == 0 
     1239    int i = 0; 
     1240    for ( typename T::const_iterator it = vec.begin(); it != vec.end(); ++it ) { 
     1241        std::ostringstream strstrm; 
     1242        strstrm << path << i; 
     1243        result &= ( *it )->serialize( strstrm.str() + "/", ser ); 
     1244        i++; 
     1245    } 
     1246    return result; 
     1247} 
     1248 
     1249template <typename T, typename VT> bool deserializeVector( Glib::ustring path, 
     1250                                                           Util::IODeserialize& deser, 
     1251                                                           AvDevice& avDevice, 
     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                                 avDevice ); 
     1262        if ( ptr ) { 
     1263            vec.push_back( ptr ); 
     1264            i++; 
     1265        } else { 
     1266            bFinished = true; 
     1267        } 
     1268    } while ( !bFinished ); 
     1269 
     1270    return true; 
     1271} 
     1272 
     1273bool 
     1274AvDevice::serializeSyncInfoVector( Glib::ustring basePath, 
     1275                                   Util::IOSerialize& ser, 
     1276                                   const SyncInfoVector& vec ) 
     1277{ 
     1278    bool result = true; 
     1279    int i = 0; 
     1280 
     1281    for ( SyncInfoVector::const_iterator it = vec.begin(); 
     1282          it != vec.end(); 
     1283          ++it ) 
     1284    { 
     1285        const SyncInfo& info = *it; 
     1286 
     1287        std::ostringstream strstrm; 
     1288        strstrm << basePath << i << "/"; 
     1289 
     1290        result &= ser.write( strstrm.str() + "m_source", info.m_source->getGlobalId() ); 
     1291        result &= ser.write( strstrm.str() + "m_destination", info.m_destination->getGlobalId() ); 
     1292        result &= ser.write( strstrm.str() + "m_description", Glib::ustring( info.m_description ) ); 
     1293 
     1294        i++; 
     1295    } 
     1296 
     1297    return result; 
     1298} 
     1299 
     1300bool 
     1301AvDevice::deserializeSyncInfoVector( Glib::ustring basePath, 
     1302                                     Util::IODeserialize& deser, 
     1303                                     AvDevice& avDevice, 
     1304                                     SyncInfoVector& vec ) 
     1305{ 
     1306    int i = 0; 
     1307    bool bFinished = false; 
     1308    do { 
     1309        bool result; 
     1310        std::ostringstream strstrm; 
     1311        strstrm << basePath << i << "/"; 
     1312 
     1313        plug_id_t sourceId; 
     1314        plug_id_t destinationId; 
     1315        Glib::ustring description; 
     1316 
     1317        result  = deser.read( strstrm.str() + "m_source", sourceId ); 
     1318        result &= deser.read( strstrm.str() + "m_destination", destinationId ); 
     1319        result &= deser.read( strstrm.str() + "m_description", description ); 
     1320 
     1321        if ( result ) { 
     1322            SyncInfo syncInfo; 
     1323            syncInfo.m_source = avDevice.getPlugManager().getPlug( sourceId ); 
     1324            syncInfo.m_destination = avDevice.getPlugManager().getPlug( destinationId ); 
     1325            syncInfo.m_description = description; 
     1326 
     1327            vec.push_back( syncInfo ); 
     1328            i++; 
     1329        } else { 
     1330            bFinished = true; 
     1331        } 
     1332    } while ( !bFinished ); 
     1333 
     1334    return true; 
     1335} 
     1336 
    12341337static bool 
    12351338deserializeAvPlugUpdateConnections( Glib::ustring path, 
     
    12491352 
    12501353bool 
    1251 AvDevice::serialize( Glib::ustring 
    1252                      basePath, Util::IOSerialize& ser ) const 
     1354AvDevice::serialize( Glib::ustring basePath, 
     1355                     Util::IOSerialize& ser ) const 
    12531356{ 
    12541357    bool result; 
     
    12581361    result &= serializeVector( basePath + "PlugConnection", ser, m_plugConnections ); 
    12591362    result &= serializeVector( basePath + "Subunit", ser, m_subunits ); 
    1260  
    1261     // XXX ... 
     1363    result &= serializeSyncInfoVector( basePath + "SyncInfo", ser, m_syncInfos ); 
     1364 
     1365    int i = 0; 
     1366    for ( SyncInfoVector::const_iterator it = m_syncInfos.begin(); 
     1367          it != m_syncInfos.end(); 
     1368          ++it ) 
     1369    { 
     1370        const SyncInfo& info = *it; 
     1371        if ( m_activeSyncInfo == &info ) { 
     1372            result &= ser.write( basePath + "m_activeSyncInfo",  i ); 
     1373            break; 
     1374        } 
     1375        i++; 
     1376    } 
     1377 
     1378    result &= ser.write( basePath + "m_id", m_id ); 
    12621379 
    12631380    return result; 
     
    12921409        result &= deserializeVector<AvPlugConnection>( basePath + "PlugConnnection", deser, *pDev, pDev->m_plugConnections ); 
    12931410        result &= deserializeVector<AvDeviceSubunit>( basePath + "Subunit",  deser, *pDev, pDev->m_subunits ); 
    1294  
    1295         // XXX ... 
     1411        result &= deserializeSyncInfoVector( basePath + "SyncInfo", deser, *pDev, pDev->m_syncInfos ); 
     1412 
     1413        unsigned int i; 
     1414        result &= deser.read( basePath + "m_activeSyncInfo", i ); 
     1415 
     1416        if ( result ) { 
     1417            if ( i < pDev->m_syncInfos.size() ) { 
     1418                pDev->m_activeSyncInfo = &pDev->m_syncInfos[i]; 
     1419            } 
     1420        } 
     1421 
     1422        result &= deser.read( basePath + "m_id", pDev->m_id ); 
    12961423    } 
    12971424 
  • trunk/libfreebob/src/bebob/bebob_avdevice.h

    r378 r379  
    8989            , m_description( description ) 
    9090            {} 
     91        SyncInfo() 
     92            : m_source( 0 ) 
     93            , m_destination( 0 ) 
     94            , m_description( "" ) 
     95            {} 
    9196        AvPlug*     m_source; 
    9297        AvPlug*     m_destination; 
     
    147152                                           AvPlugVector& prhs, 
    148153                                           std::string syncDescription ); 
     154 
     155    static bool serializeSyncInfoVector( Glib::ustring basePath, 
     156                                         Util::IOSerialize& ser, 
     157                                         const SyncInfoVector& vec ); 
     158    static bool deserializeSyncInfoVector( Glib::ustring basePath, 
     159                                           Util::IODeserialize& deser, 
     160                                           AvDevice& avDevice, 
     161                                           SyncInfoVector& vec ); 
    149162protected: 
    150163    std::auto_ptr<ConfigRom>( m_pConfigRom ); 
     
    170183}; 
    171184 
    172 template <typename T> bool serializeVector( Glib::ustring path, 
    173                                             Util::IOSerialize& ser, 
    174                                             const T& vec ) 
    175 { 
    176     bool result = true; // if vec.size() == 0 
    177     int i = 0; 
    178     for ( typename T::const_iterator it = vec.begin(); it != vec.end(); ++it ) { 
    179         std::ostringstream strstrm; 
    180         strstrm << path << i; 
    181         result &= ( *it )->serialize( strstrm.str() + "/", ser ); 
    182         i++; 
    183     } 
    184     return result; 
    185 } 
    186  
    187 template <typename T, typename VT> bool deserializeVector( Glib::ustring path, 
    188                                                            Util::IODeserialize& deser, 
    189                                                            AvDevice& avDevice, 
    190                                                            VT& vec ) 
    191 { 
    192     int i = 0; 
    193     bool bFinished = false; 
    194     do { 
    195         std::ostringstream strstrm; 
    196         strstrm << path << i << "/"; 
    197         T* ptr = T::deserialize( strstrm.str(), 
    198                                  deser, 
    199                                  avDevice ); 
    200         if ( ptr ) { 
    201             vec.push_back( ptr ); 
    202             i++; 
    203         } else { 
    204             bFinished = true; 
    205         } 
    206     } while ( !bFinished ); 
    207  
    208     return true; 
    209 } 
    210  
    211185} 
    212186 
  • trunk/libfreebob/src/libfreebobavc/avc_function_block.h

    r378 r379  
    11/* avc_function_block.h 
    2  * Copyright (C) 2006 by Daniel Wagner 
     2 * Copyright (C) 2006,07 by Daniel Wagner 
    33 * 
    44 * This file is part of FreeBoB. 
     
    165165    // Control selector encoding 
    166166    enum EControlSelectorEncoding { 
    167        eCSE_Processing_Unknown         = 0x00, 
     167        eCSE_Processing_Unknown         = 0x00, 
    168168        eCSE_Processing_Enable          = 0x01, 
    169169        eCSE_Processing_Mode            = 0x02, 
     
    200200    // CODEC type endcoding 
    201201    enum ECodecTypeEncoding { 
    202        eCTE_Unknown                    = 0x00, 
     202        eCTE_Unknown                    = 0x00, 
    203203        eCTE_Ac3Decoder                 = 0x01, 
    204204        eCTE_MpegDecoder                = 0x02,