00001 #include "SIO/SIOIntVecHandler.h"
00002
00003 #include "SIO/LCSIO.h"
00004
00005 #include "EVENT/LCIntVec.h"
00006
00007 #include "SIO_functions.h"
00008 #include "SIO_block.h"
00009
00010 using namespace EVENT ;
00011
00012
00013 namespace SIO{
00014
00015 unsigned int SIOIntVecHandler::read(SIO_stream* stream,
00016 LCObject** objP ){
00017 unsigned int status ;
00018
00019
00020 LCIntVec* vec = new LCIntVec ;
00021 *objP = vec ;
00022
00023 int nElements ;
00024 SIO_DATA( stream , &(nElements) , 1 ) ;
00025
00026
00027 for(int i=0;i<nElements;i++){
00028 int x ;
00029 SIO_DATA( stream , &x , 1 ) ;
00030 vec->push_back( x ) ;
00031 }
00032
00033 if( _vers > SIO_VERSION_ENCODE( 1, 2) ) {
00034 SIO_PTAG( stream , vec ) ;
00035 }
00036
00037 return ( SIO_BLOCK_SUCCESS ) ;
00038
00039 }
00040
00041
00042 unsigned int SIOIntVecHandler::write(SIO_stream* stream,
00043 const LCObject* obj ){
00044
00045 unsigned int status ;
00046
00047 const LCIntVec* vec = dynamic_cast<const LCIntVec*>(obj) ;
00048
00049 int nElements = vec->size() ;
00050
00051 LCSIO_WRITE( stream, nElements ) ;
00052
00053
00054
00055
00056
00057
00058 int* v_0 = const_cast<int*> ( & (*vec)[0] ) ;
00059
00060 SIO_DATA( stream , v_0 , nElements ) ;
00061
00062
00063
00064
00065
00066 SIO_PTAG( stream , vec ) ;
00067
00068 return ( SIO_BLOCK_SUCCESS ) ;
00069
00070 }
00071
00072 }