LCIO  02.17
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SIORandomAccessHandler.cc
Go to the documentation of this file.
2 
3 // -- lcio headers
4 #include "SIO/LCIORandomAccess.h"
5 #include "SIO/LCSIO.h"
6 
7 // -- sio headers
8 #include <sio/io_device.h>
9 #include <sio/version.h>
10 
11 namespace SIO {
12 
14  sio::block( LCSIO::AccessBlockName, LCSIO::blockVersion() ),
15  _randomAccess( std::make_shared<LCIORandomAccess>() ) {
16  /* nop */
17  }
18 
19  //----------------------------------------------------------------------------
20 
22  _randomAccess = ra ;
23  }
24 
25  //----------------------------------------------------------------------------
26 
28  return _randomAccess ;
29  }
30 
31  //----------------------------------------------------------------------------
32 
33  void SIORandomAccessHandler::read( sio::read_device &device, sio::version_type vers ) {
34  LCSIO::checkVersion( vers ) ;
35  SIO_SDATA( device , _randomAccess->_minRunEvt.RunNum ) ;
36  SIO_SDATA( device , _randomAccess->_minRunEvt.EvtNum ) ;
37  SIO_SDATA( device , _randomAccess->_maxRunEvt.RunNum ) ;
38  SIO_SDATA( device , _randomAccess->_maxRunEvt.EvtNum ) ;
39  SIO_SDATA( device , _randomAccess->_nRunHeaders ) ;
40  SIO_SDATA( device , _randomAccess->_nEvents ) ;
41  SIO_SDATA( device , _randomAccess->_recordsAreInOrder ) ;
42  SIO_SDATA( device , _randomAccess->_indexLocation ) ;
43  SIO_SDATA( device , _randomAccess->_prevLocation ) ;
44  SIO_SDATA( device , _randomAccess->_nextLocation ) ;
45  SIO_SDATA( device , _randomAccess->_firstRecordLocation ) ;
46  // read record size - ignored for now - need to read if record size changes in the future ...
47  int recSize ;
48  SIO_SDATA( device, recSize ) ;
49  }
50 
51  //----------------------------------------------------------------------------
52 
53  void SIORandomAccessHandler::write( sio::write_device &device ) {
54  SIO_SDATA( device , _randomAccess->_minRunEvt.RunNum ) ;
55  SIO_SDATA( device , _randomAccess->_minRunEvt.EvtNum ) ;
56  SIO_SDATA( device , _randomAccess->_maxRunEvt.RunNum ) ;
57  SIO_SDATA( device , _randomAccess->_maxRunEvt.EvtNum ) ;
58  SIO_SDATA( device , _randomAccess->_nRunHeaders ) ;
59  SIO_SDATA( device , _randomAccess->_nEvents ) ;
60  SIO_SDATA( device , _randomAccess->_recordsAreInOrder ) ;
61  SIO_SDATA( device , _randomAccess->_indexLocation ) ;
62  SIO_SDATA( device , _randomAccess->_prevLocation ) ;
63  SIO_SDATA( device , _randomAccess->_nextLocation ) ;
64  SIO_SDATA( device , _randomAccess->_firstRecordLocation ) ;
65  // write the current size of the LCIORandomAccess record as last word - incl. check at bits 31-16: 0xabcd
66  int recSize = ( 0xabcd0000 | LCSIO::RandomAccessSize ) ;
67  SIO_SDATA( device, recSize ) ;
68  }
69 
70 }
std::shared_ptr< LCIORandomAccess > _randomAccess
The random access object to read / write.
static constexpr int RandomAccessSize
Definition: LCSIO.h:31
void write(sio::write_device &device) override
std::shared_ptr< LCIORandomAccess > randomAccess() const
Get the random access object to read or write.
static void checkVersion(sio::version_type versionID)
Check for old version of LCIO (&gt; v01-08 ar no longer supported) Throws an exception if not supported...
Definition: LCSIO.cc:10
Collection of constants and helper functions.
Definition: LCSIO.h:16
Implementation class for LCIORandomAccess records.
void setRandomAccess(std::shared_ptr< LCIORandomAccess > ra)
Set the random access object to read or write.
void read(sio::read_device &device, sio::version_type vers) override