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

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

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