diff options
author | Mike Buland <eichlan@xagasoft.com> | 2010-05-25 05:42:26 +0000 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2010-05-25 05:42:26 +0000 |
commit | 286dc953c1e0e4a75589e4068e29a317a03f23dd (patch) | |
tree | 2144b0e7847222b0c6b8f6e87d8a5118e85e8b66 /src/myriad.cpp | |
parent | a0c6e974a3393642bda80fed5bce464a6c6cf2ec (diff) | |
download | libbu++-286dc953c1e0e4a75589e4068e29a317a03f23dd.tar.gz libbu++-286dc953c1e0e4a75589e4068e29a317a03f23dd.tar.bz2 libbu++-286dc953c1e0e4a75589e4068e29a317a03f23dd.tar.xz libbu++-286dc953c1e0e4a75589e4068e29a317a03f23dd.zip |
More myriad tests and features, passes perfectly so far.
Diffstat (limited to 'src/myriad.cpp')
-rw-r--r-- | src/myriad.cpp | 53 |
1 files changed, 50 insertions, 3 deletions
diff --git a/src/myriad.cpp b/src/myriad.cpp index 044e35e..9e128d1 100644 --- a/src/myriad.cpp +++ b/src/myriad.cpp | |||
@@ -352,8 +352,22 @@ int Bu::Myriad::findEmptyBlock() | |||
352 | return iBlocks++; | 352 | return iBlocks++; |
353 | } | 353 | } |
354 | 354 | ||
355 | void Bu::Myriad::deleteStream( int /*iID*/ ) | 355 | void Bu::Myriad::deleteStream( int iId ) |
356 | { | 356 | { |
357 | for( StreamArray::iterator i = aStreams.begin(); i; i++ ) | ||
358 | { | ||
359 | if( (*i)->iId == iId ) | ||
360 | { | ||
361 | Stream *pStream = *i; | ||
362 | for( BlockArray::iterator j = pStream->aBlocks.begin(); j; j++ ) | ||
363 | { | ||
364 | bsBlockUsed.setBit( *j, false ); | ||
365 | } | ||
366 | aStreams.erase( i ); | ||
367 | bHeaderChanged = true; | ||
368 | return; | ||
369 | } | ||
370 | } | ||
357 | } | 371 | } |
358 | 372 | ||
359 | Bu::MyriadStream Bu::Myriad::openStream( int iId ) | 373 | Bu::MyriadStream Bu::Myriad::openStream( int iId ) |
@@ -426,9 +440,42 @@ void Bu::Myriad::syncBlock( Block *pBlock ) | |||
426 | } | 440 | } |
427 | } | 441 | } |
428 | 442 | ||
443 | int Bu::Myriad::streamAddBlock( Stream *pStream ) | ||
444 | { | ||
445 | int iBlock = findEmptyBlock(); | ||
446 | pStream->aBlocks.append( iBlock ); | ||
447 | bsBlockUsed.setBit( iBlock ); | ||
448 | return iBlock; | ||
449 | } | ||
450 | |||
429 | void Bu::Myriad::setStreamSize( Stream *pStream, long iSize ) | 451 | void Bu::Myriad::setStreamSize( Stream *pStream, long iSize ) |
430 | { | 452 | { |
431 | sio << "Oh man, you have to implement Bu::Myriad::setStreamSize!!! (line " | 453 | if( pStream->iSize == iSize ) |
432 | << __LINE__ << ")" << sio.nl; | 454 | { |
455 | return; | ||
456 | } | ||
457 | else if( pStream->iSize > iSize ) | ||
458 | { | ||
459 | // Shrink | ||
460 | for( int iNewSize = pStream->aBlocks.getSize()*iBlockSize; | ||
461 | iNewSize-64 > iSize; iNewSize -= iBlockSize ) | ||
462 | { | ||
463 | bsBlockUsed.setBit( pStream->aBlocks.last(), false ); | ||
464 | pStream->aBlocks.eraseLast(); | ||
465 | } | ||
466 | pStream->iSize = iSize; | ||
467 | bHeaderChanged = true; | ||
468 | } | ||
469 | else | ||
470 | { | ||
471 | // Grow | ||
472 | for( int iNewSize = pStream->aBlocks.getSize()*iBlockSize; | ||
473 | iNewSize < iSize; iNewSize += iBlockSize ) | ||
474 | { | ||
475 | streamAddBlock( pStream ); | ||
476 | } | ||
477 | pStream->iSize = iSize; | ||
478 | bHeaderChanged = true; | ||
479 | } | ||
433 | } | 480 | } |
434 | 481 | ||