Changeset 379
- Timestamp:
- 01/21/07 12:22:41 (17 years ago)
- Files:
-
- trunk/libfreebob/src/bebob/bebob_avdevice.cpp (modified) (4 diffs)
- trunk/libfreebob/src/bebob/bebob_avdevice.h (modified) (3 diffs)
- trunk/libfreebob/src/libfreebobavc/avc_function_block.h (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/libfreebob/src/bebob/bebob_avdevice.cpp
r378 r379 1232 1232 } 1233 1233 1234 template <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 1249 template <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 1273 bool 1274 AvDevice::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 1300 bool 1301 AvDevice::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 1234 1337 static bool 1235 1338 deserializeAvPlugUpdateConnections( Glib::ustring path, … … 1249 1352 1250 1353 bool 1251 AvDevice::serialize( Glib::ustring 1252 basePath,Util::IOSerialize& ser ) const1354 AvDevice::serialize( Glib::ustring basePath, 1355 Util::IOSerialize& ser ) const 1253 1356 { 1254 1357 bool result; … … 1258 1361 result &= serializeVector( basePath + "PlugConnection", ser, m_plugConnections ); 1259 1362 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 ); 1262 1379 1263 1380 return result; … … 1292 1409 result &= deserializeVector<AvPlugConnection>( basePath + "PlugConnnection", deser, *pDev, pDev->m_plugConnections ); 1293 1410 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 ); 1296 1423 } 1297 1424 trunk/libfreebob/src/bebob/bebob_avdevice.h
r378 r379 89 89 , m_description( description ) 90 90 {} 91 SyncInfo() 92 : m_source( 0 ) 93 , m_destination( 0 ) 94 , m_description( "" ) 95 {} 91 96 AvPlug* m_source; 92 97 AvPlug* m_destination; … … 147 152 AvPlugVector& prhs, 148 153 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 ); 149 162 protected: 150 163 std::auto_ptr<ConfigRom>( m_pConfigRom ); … … 170 183 }; 171 184 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() == 0177 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 211 185 } 212 186 trunk/libfreebob/src/libfreebobavc/avc_function_block.h
r378 r379 1 1 /* avc_function_block.h 2 * Copyright (C) 2006 by Daniel Wagner2 * Copyright (C) 2006,07 by Daniel Wagner 3 3 * 4 4 * This file is part of FreeBoB. … … 165 165 // Control selector encoding 166 166 enum EControlSelectorEncoding { 167 167 eCSE_Processing_Unknown = 0x00, 168 168 eCSE_Processing_Enable = 0x01, 169 169 eCSE_Processing_Mode = 0x02, … … 200 200 // CODEC type endcoding 201 201 enum ECodecTypeEncoding { 202 202 eCTE_Unknown = 0x00, 203 203 eCTE_Ac3Decoder = 0x01, 204 204 eCTE_MpegDecoder = 0x02,