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

Go to the documentation of this file.
00001 #include "SIO/SIOLCParameters.h"
00002 
00003 #include "SIO/LCSIO.h"
00004 
00005 #include "SIO_functions.h"
00006 #include "SIO_block.h"
00007 
00008 using namespace EVENT ;
00009 
00010 
00011 namespace SIO{
00012     
00013   unsigned int SIOLCParameters::read(SIO_stream* stream, 
00014                                      LCParameters& params,  
00015                                      unsigned int vers) {
00016 
00017     unsigned int status ; 
00018         
00019         
00020     int nIntParameters ;
00021     SIO_DATA( stream , &nIntParameters , 1 ) ;
00022 
00023     for(int i=0; i< nIntParameters ; i++ ){
00024 
00025       char* keyTmp ; 
00026       LCSIO_READ( stream,  &keyTmp ) ; 
00027       std::string key( keyTmp ) ;
00028 
00029       int nInt  ;
00030       SIO_DATA( stream , &nInt , 1 ) ;
00031       IntVec intVec(nInt) ;
00032 
00033       for(int j=0; j< nInt ; j++ ){
00034           SIO_DATA( stream , &intVec[j]  , 1 ) ;
00035       }
00036       params.setValues( key , intVec ) ;
00037     }
00038 
00039     int nFloatParameters ;
00040     SIO_DATA( stream , &nFloatParameters , 1 ) ;
00041 
00042     for(int i=0; i< nFloatParameters ; i++ ){
00043 
00044       char* keyTmp ; 
00045       LCSIO_READ( stream,  &keyTmp ) ; 
00046       std::string key( keyTmp ) ;
00047 
00048       int nFloat  ;
00049       SIO_DATA( stream , &nFloat , 1 ) ;
00050       FloatVec floatVec(nFloat) ;
00051 
00052       for(int j=0; j< nFloat ; j++ ){
00053           SIO_DATA( stream , &floatVec[j]  , 1 ) ;
00054       }
00055       params.setValues( key , floatVec ) ;
00056     }
00057 
00058     int nStringParameters ;
00059     SIO_DATA( stream , &nStringParameters , 1 ) ;
00060 
00061     for(int i=0; i< nStringParameters ; i++ ){
00062 
00063       char* keyTmp ; 
00064       LCSIO_READ( stream,  &keyTmp ) ; 
00065       std::string key( keyTmp ) ;
00066 
00067       int nString  ;
00068       SIO_DATA( stream , &nString , 1 ) ;
00069       StringVec stringVec(nString) ;
00070 
00071       for(int j=0; j< nString ; j++ ){
00072         char* valTmp ; 
00073         LCSIO_READ( stream,  &valTmp ) ; 
00074         stringVec[j] = valTmp ;
00075       }
00076       params.setValues( key , stringVec ) ;
00077     }
00078 
00079 
00080 
00081 
00082 
00083     return ( SIO_BLOCK_SUCCESS ) ;
00084         
00085   }
00086     
00087     
00088   unsigned int SIOLCParameters::write(SIO_stream* stream, 
00089                                       const LCParameters& params) {
00090     
00091     unsigned int status ; 
00092 
00093     StringVec intKeys ;
00094     int nIntParameters = params.getIntKeys( intKeys ).size() ;
00095 
00096     SIO_DATA( stream , &nIntParameters , 1 ) ;
00097 
00098     for(int i=0; i< nIntParameters ; i++ ){
00099 
00100       IntVec intVec ;
00101 
00102       params.getIntVals(  intKeys[i], intVec ) ;
00103 
00104       int nInt  = intVec.size()  ;     // = params.getNInt( intKeys[i] ) ;
00105 
00106 //       if( nInt > 0 ){ 
00107 
00108         LCSIO_WRITE( stream, intKeys[i]  ) ;
00109         SIO_DATA( stream , &nInt , 1 ) ;
00110 
00111 
00112         for(int j=0; j< nInt ; j++ ){
00113           LCSIO_WRITE( stream, intVec[j]  ) ;
00114         }
00115 //       }
00116     }
00117 
00118     StringVec floatKeys ;
00119     int nFloatParameters = params.getFloatKeys( floatKeys ).size() ;
00120     
00121     SIO_DATA( stream , &nFloatParameters , 1 ) ;
00122 
00123     for(int i=0; i< nFloatParameters ; i++ ){
00124 
00125       FloatVec floatVec ;
00126 
00127       params.getFloatVals(  floatKeys[i], floatVec ) ;
00128 
00129       int nFloat  = floatVec.size()  ;     // = params.getNFloat( floatKeys[i] ) ;
00130 
00131 //       if( nFloat > 0 ){ 
00132 
00133         LCSIO_WRITE( stream, floatKeys[i]  ) ;
00134         SIO_DATA( stream , &nFloat , 1 ) ;
00135 
00136 
00137         for(int j=0; j< nFloat ; j++ ){
00138           LCSIO_WRITE( stream, floatVec[j]  ) ;
00139         }
00140 //       }
00141     }
00142     
00143     StringVec stringKeys ;
00144     int nStringParameters = params.getStringKeys( stringKeys ).size() ;
00145     
00146     SIO_DATA( stream , &nStringParameters , 1 ) ;
00147     
00148     for(int i=0; i< nStringParameters ; i++ ){
00149       
00150       StringVec stringVec ;
00151       
00152       params.getStringVals(  stringKeys[i], stringVec ) ;
00153       
00154       int nString  = stringVec.size()  ;     // = params.getNString( stringKeys[i] ) ;
00155       
00156 //       if( nString > 0 ){ 
00157         
00158         LCSIO_WRITE( stream, stringKeys[i]  ) ;
00159         SIO_DATA( stream , &nString , 1 ) ;
00160         
00161         
00162         for(int j=0; j< nString ; j++ ){
00163           LCSIO_WRITE( stream, stringVec[j]  ) ;
00164         }
00165 //       }
00166     }
00167 
00168 
00169 //     int nElements = vec->size() ;
00170     
00171 //     //    cout << " >>>>> writing  LCParameters - size : " << nElements << ": " ;
00172 //     LCSIO_WRITE( stream, nElements ) ;
00173 //     for(int i=0;i<nElements;i++){
00174 //       LCSIO_WRITE( stream, (*vec)[i] ) ;
00175 //       //cout <<  (*vec)[i] <<   ", " ; 
00176 //     }    
00177 //     //    cout << endl ;
00178 
00179     return ( SIO_BLOCK_SUCCESS ) ;
00180     
00181   }
00182   
00183 } // namespace

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