CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_14/src/CondCore/RegressionTest/src/ArrayPayload.cc

Go to the documentation of this file.
00001 #include "CondCore/RegressionTest/interface/ArrayPayload.h"
00002 #include <sstream>
00003 
00004 Param::Param():
00005   p_i( -1 ),
00006   p_s(""){
00007 }
00008 
00009 Param::Param( int seed ):
00010   p_i( seed ),
00011   p_s(""){
00012   std::stringstream ss;
00013   ss << seed;
00014   p_s = ss.str();   
00015 }
00016 
00017 bool Param::operator ==(const Param& rhs) const {
00018   if( p_i != rhs.p_i ) return false;
00019   if( p_s != rhs.p_s ) return false;
00020   return true;  
00021 }
00022 
00023 bool Param::operator !=(const Param& rhs) const {
00024   return !operator==( rhs );
00025 }
00026 
00027 void setDefaultBitSet( std::bitset<128>& val ){
00028   size_t i = 0;
00029   while( i<128 ){
00030     if( i%2==0 ) val.set(i);
00031     i++;
00032   }
00033 }
00034 
00035 ArrayPayload::ArrayPayload():
00036   m_i(-1),
00037   m_p0(),
00038   m_p1(),
00039   m_p2(),
00040   m_vec0(),
00041   m_vec1(),
00042   m_map0(),
00043   m_map1(),
00044   m_list(),
00045   m_set(),
00046   m_bitset(),
00047   m_vec2(),
00048   m_map2(),
00049   m_vec3(){
00050   setDefaultBitSet( m_bitset );
00051 }
00052 
00053 ArrayPayload::ArrayPayload( int seed ):
00054   m_i( seed + 99 ),
00055   m_p0(),
00056   m_p1(),
00057   m_p2(),
00058   m_vec0(),
00059   m_vec1(),
00060   m_map0(),
00061   m_map1(),
00062   m_list(),
00063   m_set(),
00064   m_bitset(),
00065   m_vec2(),
00066   m_map2(),
00067   m_vec3(){
00068   for( size_t i=0;i<4; i++ ){
00069     m_ai0[i]= seed + i;
00070   }
00071   for( size_t i=0;i<112; i++ ){
00072     m_ai1[i]= seed + i;
00073   }
00074   for( size_t i=0;i<2; i++ ){
00075     for( size_t j=0;i<3; i++ ){
00076       m_ai2[j][i]= seed + i + j;
00077     }
00078   }
00079   for( size_t i=0;i<80; i++ ){
00080     for( size_t j=0;i<2; i++ ){
00081       m_ai3[j][i]= seed + i + j;
00082     }
00083   }
00084   for( size_t i=0;i<4; i++ ){
00085     std::stringstream ss;
00086     ss << (seed + i);
00087     m_as0[i]= ss.str();
00088   }
00089   for( size_t i=0;i<112; i++ ){
00090     std::stringstream ss;
00091     ss << (seed + i);
00092     m_as1[i]= ss.str();
00093   }
00094   for( int i=0;i<4; i++ ){
00095     m_ap0[i] = Param(i+seed);
00096   }
00097   for( int i=0;i<112; i++ ){
00098     m_ap1[i] = Param(i+seed);
00099   }
00100   m_p0.first = seed;
00101   m_p0.second = seed*10;
00102   m_p1.first = seed;
00103   std::stringstream ss;
00104   ss << (seed*10);
00105   m_p1.second = ss.str();
00106   m_p2.first = seed;
00107   m_p2.second = Param( seed );
00108   
00109   for( int i=0;i<seed;i++){
00110     m_vec0.push_back(i);
00111     std::stringstream ss0;
00112     ss0 << "vec1_"<<seed;
00113     m_vec1.push_back( ss0.str() );
00114     m_map0.insert(std::make_pair((unsigned int)seed,(unsigned int)seed));
00115     std::stringstream ss1;
00116     ss1 << "map1_"<<seed;
00117     m_map1.insert(std::make_pair( ss1.str(),ss1.str() ) );
00118     m_list.push_back( seed );
00119     m_set.insert( ss1.str() );
00120     m_vec2.push_back( Param( seed ) );
00121     m_map2.insert( std::make_pair( seed, Param( seed ) ) );
00122     m_vec3.push_back( Param( seed ) );
00123   }
00124   
00125   size_t i=0;
00126   int j = 1;
00127   while( j<128 ){
00128     if( seed & j )m_bitset.set(i);
00129     j = j << 1;
00130     i++;
00131   }
00132 }
00133 
00134 #include <iostream>
00135 bool ArrayPayload::operator ==(const ArrayPayload& rhs) const {
00136   if( m_i != rhs.m_i ) return false;
00137   for( int i=0;i<4;i++){
00138     if(m_ai0[i] != rhs.m_ai0[i] ) return false;
00139   }
00140   for( int i=0;i<112;i++){
00141     if(m_ai1[i] != rhs.m_ai1[i] ) return false;
00142   }
00143   for( size_t i=0;i<2; i++ ){
00144     for( size_t j=0;i<3; i++ ){
00145       if( m_ai2[j][i] != rhs.m_ai2[j][i] ) return false;
00146     }
00147   }
00148   for( size_t i=0;i<80; i++ ){
00149     for( size_t j=0;i<2; i++ ){
00150       if( m_ai3[j][i] != rhs.m_ai3[j][i] ) return false;
00151     }
00152   }
00153   for( size_t i=0;i<4; i++ ){
00154     if(m_as0[i] != rhs.m_as0[i] ) return false;
00155   }
00156   for( size_t i=0;i<112; i++ ){
00157     if(m_as1[i] != rhs.m_as1[i] ) return false;
00158   }
00159   for( int i=0;i<4; i++ ){
00160     if(m_ap0[i] != rhs.m_ap0[i] ) return false;
00161   }
00162   for( int i=0;i<112; i++ ){
00163     if(m_ap1[i] != rhs.m_ap1[i] ) return false;
00164   }
00165   if(m_p0 != rhs.m_p0 ) return false;
00166   if(m_p1 != rhs.m_p1 ) return false;
00167   if(m_p2 != rhs.m_p2 ) return false;
00168   if(m_vec0 != rhs.m_vec0 ) return false;
00169   if(m_vec1 != rhs.m_vec1 ) return false;
00170   if(m_vec2 != rhs.m_vec2 ) return false;
00171   if(m_vec3 != rhs.m_vec3 ) return false;
00172   if(m_map0 != rhs.m_map0 ) return false;
00173   if(m_map1 != rhs.m_map1 ) return false;
00174   if(m_map2 != rhs.m_map2 ) return false;
00175   if(m_list != rhs.m_list ) return false;
00176   if(m_set != rhs.m_set ) return false;
00177   std::bitset<128> defValue;
00178   setDefaultBitSet( defValue );
00179   if( m_bitset == defValue ){
00180     std::cout <<"WARNING: data member \"m_bitset\" read with the default value."<<std::endl;
00181   } else {
00182     if( m_bitset != rhs.m_bitset ) return false;
00183   }
00184   return true;
00185 }
00186   
00187 bool ArrayPayload::operator !=(const ArrayPayload& rhs) const {
00188   return !operator==(rhs);
00189 }