00001 #include "SIO/SIOFloatVecHandler.h"
00002
00003 #include "SIO/LCSIO.h"
00004
00005 #include "EVENT/LCFloatVec.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 SIOFloatVecHandler::read(SIO_stream* stream,
00016 LCObject** objP ){
00017 unsigned int status ;
00018
00019
00020 LCFloatVec* vec = new LCFloatVec ;
00021 *objP = vec ;
00022
00023 int nElements ;
00024 SIO_DATA( stream , &(nElements) , 1 ) ;
00025
00026
00027 for(int i=0;i<nElements;i++){
00028 float 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 SIOFloatVecHandler::write(SIO_stream* stream,
00043 const LCObject* obj ){
00044
00045 unsigned int status ;
00046
00047 const LCFloatVec* vec = dynamic_cast<const LCFloatVec*>(obj) ;
00048
00049 int nElements = vec->size() ;
00050
00051
00052 LCSIO_WRITE( stream, nElements ) ;
00053 for(int i=0;i<nElements;i++){
00054 LCSIO_WRITE( stream, (*vec)[i] ) ;
00055
00056 }
00057
00058
00059 SIO_PTAG( stream , vec ) ;
00060
00061 return ( SIO_BLOCK_SUCCESS ) ;
00062
00063 }
00064
00065 }