#include <SIO_record.h>
Collaboration diagram for SIO_record:

Public Member Functions | |
| unsigned int | connect (const char *) |
| unsigned int | connect (SIO_block *) |
| unsigned int | disconnect (const char *) |
| unsigned int | disconnect (SIO_block *) |
| SIO_block * | getConnect (const char *) |
| bool | getCompress () |
| std::string * | getName () |
| bool | getUnpack () |
| SIO_verbosity | getVerbosity () |
| bool | setCompress (bool) |
| bool | setUnpack (bool) |
| SIO_verbosity | setVerbosity (SIO_verbosity) |
Private Member Functions | |
| SIO_record (const char *, SIO_verbosity) | |
| ~SIO_record () | |
| unsigned int | connect (std::string *, SIO_block *) |
| unsigned int | disconnect (std::string *, SIO_block *) |
| unsigned int | getOptions () |
| unsigned int | read (SIO_stream *, unsigned int) |
| unsigned int | write (SIO_stream *) |
Private Attributes | |
| connectMap_c | connectMap |
| std::string | name |
| unsigned int | options |
| bool | unpack |
| SIO_verbosity | verbosity |
Friends | |
| class | SIO_recordManager |
| class | SIO_stream |
|
||||||||||||
|
Definition at line 33 of file SIO_record.cc. References SIO_verbosity.
|
|
|
Definition at line 47 of file SIO_record.cc.
00047 {}
|
|
||||||||||||
|
Definition at line 128 of file SIO_record.cc. References SIO_ALL, SIO_ERRORS, SIO_RECORD_DUPCONNECT, and SIO_RECORD_SUCCESS.
00132 {
00133
00134 //
00135 // Local variables.
00136 //
00137 std::pair< connectMap_i, bool >
00138 status;
00139
00140 //
00141 // Initialize the map entry.
00142 //
00143 std::pair< std::string const, SIO_block* >
00144 entry( *s_name, block );
00145
00146 //
00147 // Insert the entry. This may or may not succeed depending on whether the
00148 // name pre-exists.
00149 //
00150 status = connectMap.insert( entry );
00151 if( status.second )
00152 {
00153 if( verbosity >= SIO_ALL )
00154 {
00155 std::cout << "SIO: [/" << name << "/" << entry.first << "] "
00156 << "Connected"
00157 << std::endl;
00158 }
00159 }
00160 else
00161 {
00162 if( verbosity >= SIO_ERRORS )
00163 {
00164 std::cout << "SIO: [/" << name << "/" << entry.first << "] "
00165 << "Already connected"
00166 << std::endl;
00167 }
00168 return( SIO_RECORD_DUPCONNECT );
00169 }
00170
00171 //
00172 // That's all folks!
00173 //
00174 return( SIO_RECORD_SUCCESS );
00175 }
|
|
|
Definition at line 92 of file SIO_record.cc. References SIO_ERRORS, and SIO_RECORD_BADARGUMENT.
00095 {
00096
00097 //
00098 // Local variables.
00099 //
00100 std::string
00101 s_name;
00102
00103 //
00104 // Validate the block pointer.
00105 //
00106 if( block == NULL )
00107 {
00108 if( verbosity >= SIO_ERRORS )
00109 {
00110 std::cout << "SIO: [/" << name << "/] "
00111 << "SIO: Block not connected (pointer is NULL)"
00112 << std::endl;
00113 }
00114 return( SIO_RECORD_BADARGUMENT );
00115 }
00116 s_name = *(block->getName());
00117
00118 //
00119 // Go to the workhorse.
00120 //
00121 return( connect( &s_name, block ) );
00122 }
|
|
|
Definition at line 53 of file SIO_record.cc. References SIO_blockManager::get(), SIO_ERRORS, and SIO_RECORD_BADARGUMENT. Referenced by CalorimeterSIO::CalorimeterSIO(), LCDG4EventAction::EndOfEventAction(), LCDG4_SIOglobal::LCDG4_SIOglobal(), MCPrintSIO::MCPrintSIO(), MuonSIO::MuonSIO(), TrackerSIO::TrackerSIO(), and VxdSIO::VxdSIO().
00056 {
00057
00058 //
00059 // Local variables.
00060 //
00061 SIO_block
00062 *block;
00063
00064 std::string
00065 s_name = i_name;
00066
00067 //
00068 // Validate the name.
00069 //
00070 block = SIO_blockManager::get( i_name );
00071 if( block == NULL )
00072 {
00073 if( verbosity >= SIO_ERRORS )
00074 {
00075 std::cout << "SIO: [/" << name << "/" << i_name << "] "
00076 << "Block not connected (name not recognized)"
00077 << std::endl;
00078 }
00079 return( SIO_RECORD_BADARGUMENT );
00080 }
00081
00082 //
00083 // Go to the workhorse.
00084 //
00085 return( connect( &s_name, block ) );
00086 }
|
|
||||||||||||
|
Definition at line 256 of file SIO_record.cc. References connectMap_i, SIO_ALL, SIO_ERRORS, SIO_RECORD_NOTCONNECTED, and SIO_RECORD_SUCCESS.
00260 {
00261 if(block) ; // make compiler happy
00262 //
00263 // Local variables.
00264 //
00265 connectMap_i
00266 iter;
00267
00268 //
00269 // Use the map's find function. It the name doesn't exist, return an error.
00270 //
00271 if( (iter = connectMap.find( *s_name )) == connectMap.end() )
00272 {
00273 if( verbosity >= SIO_ERRORS )
00274 {
00275 std::cout << "SIO: [/" << name << "/" << *s_name << "] "
00276 << "Not disconnected (block is not connected)"
00277 << std::endl;
00278 }
00279 return( SIO_RECORD_NOTCONNECTED );
00280 }
00281
00282 //
00283 // Remove the connection in the connection map.
00284 //
00285 connectMap.erase( iter );
00286
00287 if( verbosity >= SIO_ALL )
00288 {
00289 std::cout << "SIO: [/" << name << "/" << *s_name << "] "
00290 << "Disconnected"
00291 << std::endl;
00292 }
00293
00294 //
00295 // That's all folks!
00296 //
00297 return( SIO_RECORD_SUCCESS );
00298 }
|
|
|
Definition at line 220 of file SIO_record.cc. References SIO_ERRORS, and SIO_RECORD_BADARGUMENT.
00223 {
00224
00225 //
00226 // Local variables.
00227 //
00228 std::string
00229 s_name;
00230
00231 //
00232 // Validate the block pointer.
00233 //
00234 if( block == NULL )
00235 {
00236 if( verbosity >= SIO_ERRORS )
00237 {
00238 std::cout << "SIO: [/" << name << "/] "
00239 << "Not disconnected (pointer is NULL)"
00240 << std::endl;
00241 }
00242 return( SIO_RECORD_BADARGUMENT );
00243 }
00244 s_name = *(block->getName());
00245
00246 //
00247 // Go to the workhorse.
00248 //
00249 return( disconnect( &s_name, block ) );
00250 }
|
|
|
Definition at line 181 of file SIO_record.cc. References SIO_blockManager::get(), SIO_ERRORS, and SIO_RECORD_BADARGUMENT.
00184 {
00185
00186 //
00187 // Local variables.
00188 //
00189 SIO_block
00190 *block;
00191
00192 std::string
00193 s_name = i_name;
00194
00195 //
00196 // Validate the name.
00197 //
00198 block = SIO_blockManager::get( i_name );
00199 if( block == NULL )
00200 {
00201 if( verbosity >= SIO_ERRORS )
00202 {
00203 std::cout << "SIO: [/" << name << "/" << i_name << "] "
00204 << "Not disconnected (block name not recognized)"
00205 << std::endl;
00206 }
00207 return( SIO_RECORD_BADARGUMENT );
00208 }
00209
00210 //
00211 // Go to the workhorse.
00212 //
00213 return( disconnect( &s_name, block ) );
00214 }
|
|
|
Definition at line 348 of file SIO_record.cc. References options, and SIO_OPT_COMPRESS.
00349 {
00350 if( (options & SIO_OPT_COMPRESS) != 0 )
00351 return( true );
00352
00353 return( false );
00354 }
|
|
|
Definition at line 304 of file SIO_record.cc. References connectMap_i, SIO_ALL, and SIO_ERRORS.
00307 {
00308
00309 //
00310 // Local variables.
00311 //
00312 connectMap_i
00313 iter;
00314
00315 std::string
00316 s_name = i_name;
00317
00318 //
00319 // Use the map's find function. It the name doesn't exist, return NULL.
00320 //
00321 if( (iter = connectMap.find( s_name )) == connectMap.end() )
00322 {
00323 if( verbosity >= SIO_ERRORS )
00324 {
00325 std::cout << "SIO: [/" << name << "/" << i_name << "] "
00326 << "Block is not connected"
00327 << std::endl;
00328 }
00329 return( NULL );
00330 }
00331
00332 if( verbosity >= SIO_ALL )
00333 {
00334 std::cout << "SIO: [/" << name << "/" << i_name << "] "
00335 << "Block is connected"
00336 << std::endl;
00337 }
00338
00339 //
00340 // That's all folks!
00341 //
00342 return( iter->second );
00343 }
|
|
|
Definition at line 359 of file SIO_record.cc. References name.
00359 { return( &name ); }
|
|
|
Definition at line 364 of file SIO_record.cc. References options.
00364 { return( options ); }
|
|
|
Definition at line 369 of file SIO_record.cc. References unpack.
00369 { return( unpack ); }
|
|
|
Definition at line 374 of file SIO_record.cc. References SIO_verbosity, and verbosity.
00374 { return( verbosity ); }
|
|
||||||||||||
|
Definition at line 380 of file SIO_record.cc. References SIO_blockManager::get(), pointedAtMap_i, pointerToMap_i, SIO_DATA, SIO_ERRORS, SIO_mark_block, SIO_OP_READ, SIO_POINTER_DECL, SIO_RECORD_NOBLKMARKER, SIO_RECORD_SUCCESS, SIO_STREAM_NOALLOC, and SIO_block::xfer().
00384 {
00385
00386 //
00387 // Local variables.
00388 //
00389 SIO_block
00390 *block;
00391
00392 pointedAtMap_i
00393 pati;
00394
00395 pointerToMap_i
00396 ptoh,
00397 ptoi,
00398 ptol;
00399
00400 SIO_POINTER_DECL
00401 *pointer;
00402
00403 unsigned int
00404 buflen,
00405 buftyp,
00406 status,
00407 tmplen,
00408 version;
00409
00410 char
00411 *tmploc;
00412
00413 //
00414 // Save the options.
00415 //
00416 options = i_options;
00417
00418 //
00419 // Walk along the record buffer unpacking blocks.
00420 //
00421 while( stream->buffer < stream->recmax )
00422 {
00423 //
00424 // Set the block maximum marker out of the way while interpreting the
00425 // block length and type (but even so, don't let reads escape off the
00426 // total length of the buffer!
00427 //
00428 stream->blkmax = stream->recmax;
00429
00430 //
00431 // Interpret: 1) The length of the block.
00432 // 2) The block marker.
00433 //
00434 SIO_DATA( stream, &buflen, 1 );
00435 SIO_DATA( stream, &buftyp, 1 );
00436 if( buftyp != SIO_mark_block )
00437 {
00438 if( verbosity >= SIO_ERRORS )
00439 {
00440 std::cout << "SIO: [" << stream->name << "/" << name << "/] "
00441 << "Expected block marker not found"
00442 << std::endl;
00443 }
00444 return( SIO_RECORD_NOBLKMARKER );
00445 }
00446 stream->blkmax = stream->buffer + buflen - 8;
00447
00448 //
00449 // Read the block version.
00450 //
00451 SIO_DATA( stream, &version, 1 );
00452
00453 //
00454 // Read and interpret the block name.
00455 //
00456 SIO_DATA( stream, &tmplen, 1 );
00457
00458 tmploc = static_cast<char *>(malloc( tmplen + 1 ));
00459 if( tmploc == NULL )
00460 {
00461 if( verbosity >= SIO_ERRORS )
00462 {
00463 std::cout << "SIO: [" << stream->name << "/" << name << "/] "
00464 << "Buffer allocation failed"
00465 << std::endl;
00466 }
00467 return( SIO_STREAM_NOALLOC );
00468 }
00469
00470 SIO_DATA( stream, tmploc, tmplen );
00471 tmploc[tmplen] = '\0';
00472 block = SIO_blockManager::get( tmploc );
00473 stream->blk_name = tmploc;
00474 free( tmploc );
00475
00476 //
00477 // Try to unpack the block.
00478 //
00479 if( block != NULL )
00480 {
00481 status = block->xfer( stream, SIO_OP_READ, version );
00482 if( !(status & 1) )
00483 return( status );
00484 }
00485
00486 else
00487 stream->buffer = stream->blkmax;
00488 }
00489
00490 //
00491 // Pointer relocation on read.
00492 //
00493 // Some of these variables are a little terse! Expanded meanings:
00494 //
00495 // ptol: Iterator pointing to lower bound in the 'pointer to' multimap
00496 // ptoh: Iterator pointing to upper bound in the 'pointer to' multimap
00497 // ptoi: Iterator for the 'pointer to' multimap (runs [ptol, ptoh) )
00498 // pati: Iterator in the 'pointed at' map (search map for ptol->first)
00499 //
00500 ptol = stream->pointerTo->begin();
00501 while( ptol != stream->pointerTo->end() )
00502 {
00503 ptoh = stream->pointerTo->upper_bound( ptol->first );
00504 pati = stream->pointedAt->find( ptol->first );
00505
00506 if( pati != stream->pointedAt->end() )
00507 {
00508 for( ptoi = ptol; ptoi != ptoh; ptoi++ )
00509 {
00510 pointer = static_cast <SIO_POINTER_DECL *>(ptoi->second);
00511 *pointer = reinterpret_cast<SIO_POINTER_DECL >(pati->second);
00512 }
00513 }
00514 ptol = ptoh;
00515 }
00516
00517 //
00518 // That's all folks!
00519 //
00520 return( SIO_RECORD_SUCCESS );
00521 }
|
|
|
Definition at line 527 of file SIO_record.cc. References SIO_OPT_COMPRESS.
00530 {
00531 unsigned int
00532 o_options = (options & SIO_OPT_COMPRESS);
00533
00534 options &= ~SIO_OPT_COMPRESS;
00535 if( compress ) options |= SIO_OPT_COMPRESS;
00536
00537 if( o_options != 0 )
00538 return( true );
00539
00540 return( false );
00541 }
|
|
|
Definition at line 547 of file SIO_record.cc.
00550 { bool o_unpack = unpack; unpack = i_unpack; return( o_unpack ); }
|
|
|
Definition at line 556 of file SIO_record.cc. References SIO_verbosity.
00559 { SIO_verbosity o_verb = verbosity; verbosity = i_verb; return( o_verb ); }
|
|
|
Definition at line 565 of file SIO_record.cc. References connectMap_i, SIO_functions::copy(), pointedAtMap_i, pointerToMap_i, SIO_BLOCK_SUCCESS, SIO_DATA, SIO_ERRORS, SIO_LEN_QB, SIO_mark_block, SIO_OP_WRITE, SIO_RECORD_SUCCESS, and UCHR_CAST.
00568 {
00569
00570 //
00571 // Local variables.
00572 //
00573 pointedAtMap_i
00574 pati;
00575
00576 pointerToMap_i
00577 ptoh,
00578 ptoi,
00579 ptol;
00580
00581
00582 connectMap_i
00583 iter;
00584
00585 unsigned int
00586 blkver,
00587 buflen,
00588 match,
00589 namlen,
00590 status;
00591
00592 unsigned char
00593 *pointer;
00594
00595 const char
00596 *nampnt;
00597
00598 //
00599 // Loop over blocks, getting their input.
00600 //
00601 for( iter = connectMap.begin(); iter != connectMap.end(); iter++ )
00602 {
00603 //
00604 // Save the beginning of block pointer. Reuse the stream->blkmax variable
00605 // (which has no use during buffer writing) to save it so that if the copy
00606 // routine in SIO_functions is forced to reallocate the output buffer,
00607 // the pointer to the beginning of block can be updated as well.
00608 //
00609 stream->blkmax = stream->buffer;
00610
00611 //
00612 // Output: 1) A placeholder where the block length will go.
00613 // 2) A 'framing' marker (to help in debugging).
00614 // 3) The version of the block.
00615 // 4) The length of the block name.
00616 // 5) The block name.
00617 //
00618 SIO_DATA( stream, &SIO_mark_block, 1 );
00619 SIO_DATA( stream, &SIO_mark_block, 1 );
00620
00621 blkver = iter->second->version();
00622 SIO_DATA( stream, &blkver, 1 );
00623
00624 namlen = iter->first.size();
00625 nampnt = iter->first.c_str();
00626
00627 SIO_DATA( stream, &namlen, 1 );
00628 SIO_DATA( stream, const_cast<char *>(nampnt), namlen );
00629
00630 //
00631 // Write the block content.
00632 //
00633 status = iter->second->xfer( stream, SIO_OP_WRITE, blkver );
00634 if( status != SIO_BLOCK_SUCCESS )
00635 {
00636 if( verbosity >= SIO_ERRORS )
00637 {
00638 std::cout << "SIO: ["
00639 << stream->name << "/"
00640 << name << "/"
00641 << iter->first << "] "
00642 << "Write error"
00643 << std::endl;
00644 }
00645 return( status );
00646 }
00647
00648 //
00649 // Back fill the length of the block.
00650 //
00651 buflen = stream->buffer - stream->blkmax;
00652 SIO_functions::copy( UCHR_CAST(&buflen),
00653 stream->blkmax, SIO_LEN_QB, 1 );
00654 }
00655
00656 //
00657 // Pointer relocation on write.
00658 //
00659 // Some of these variables are a little terse! Expanded meanings:
00660 //
00661 // ptol: Iterator pointing to lower bound in the 'pointer to' multimap
00662 // ptoh: Iterator pointing to upper bound in the 'pointer to' multimap
00663 // ptoi: Iterator for the 'pointer to' multimap (runs [ptol, ptoh) )
00664 // pati: Iterator in the 'pointed at' map (search map for ptol->first)
00665 //
00666
00667 //
00668 // The next piece of code was just too valuable a debugging tool to toss out!
00669 //
00670 /*
00671 printf("\nPointer to:\n\n" );
00672 for( ptoi = stream->pointerTo->begin();
00673 ptoi != stream->pointerTo->end();
00674 ptoi++ )
00675 {
00676 printf("%016lx %016lx\n", ptoi->first, ptoi->second );
00677 }
00678
00679 printf("\nPointed at:\n\n" );
00680 for( pati = stream->pointedAt->begin();
00681 pati != stream->pointedAt->end();
00682 pati++ )
00683 {
00684 printf("%016lx %016lx\n", pati->first, pati->second );
00685 }
00686 */
00687
00688 match = 0x00000001;
00689 ptol = stream->pointerTo->begin();
00690 while( ptol != stream->pointerTo->end() )
00691 {
00692 ptoh = stream->pointerTo->upper_bound( ptol->first );
00693 pati = stream->pointedAt->find( ptol->first );
00694
00695 if( pati != stream->pointedAt->end() )
00696 {
00697 pointer = stream->bufloc +
00698 reinterpret_cast<SIO_POINTER_DECL>(pati->second);
00699
00700 SIO_functions::copy( UCHR_CAST( &match ), pointer, SIO_LEN_QB, 1 );
00701
00702 for( ptoi = ptol; ptoi != ptoh; ptoi++ )
00703 {
00704 pointer = stream->bufloc +
00705 reinterpret_cast<SIO_POINTER_DECL>(ptoi->second);
00706
00707 SIO_functions::copy( UCHR_CAST( &match ), pointer, SIO_LEN_QB, 1 );
00708 }
00709 }
00710
00711 match++;
00712 ptol = ptoh;
00713 }
00714
00715 //
00716 // That's all folks!
00717 //
00718 return( SIO_RECORD_SUCCESS );
00719 }
|
|
|
Definition at line 64 of file SIO_record.h. |
|
|
Definition at line 65 of file SIO_record.h. |
|
|
Definition at line 58 of file SIO_record.h. |
|
|
Definition at line 59 of file SIO_record.h. Referenced by getName(). |
|
|
Definition at line 60 of file SIO_record.h. Referenced by getCompress(), and getOptions(). |
|
|
Definition at line 61 of file SIO_record.h. Referenced by getUnpack(). |
|
|
Definition at line 62 of file SIO_record.h. Referenced by getVerbosity(). |
1.3.4