/data3/calcul/jacquem/working_dir/Micromegas/micromegasFrameWork/lcio/src/cpp/src/SIO/SIOFloatVecHandler.cc

Go to the documentation of this file.
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     // create a new object :
00020     LCFloatVec* vec  = new LCFloatVec ;
00021     *objP = vec ;
00022         
00023     int nElements ;
00024     SIO_DATA( stream ,  &(nElements) , 1  ) ;
00025 
00026     //    float* x = new float[]( nElements ) ;
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     //    cout << " >>>>> writing  LCFloatVec - size : " << nElements << ": " ;
00052     LCSIO_WRITE( stream, nElements ) ;
00053     for(int i=0;i<nElements;i++){
00054       LCSIO_WRITE( stream, (*vec)[i] ) ;
00055       //cout <<  (*vec)[i] <<   ", " ; 
00056     }    
00057     //    cout << endl ;
00058 
00059     SIO_PTAG( stream , vec ) ;
00060 
00061     return ( SIO_BLOCK_SUCCESS ) ;
00062     
00063   }
00064   
00065 } // namespace

Generated on Mon Jan 7 13:15:21 2013 for MicromegasFramework by  doxygen 1.4.7