Show
Ignore:
Timestamp:
08/05/09 14:40:03 (15 years ago)
Author:
mido
Message:

panove, vite, jak jsem peclivej na upravu kodu.. snad se vam bude libit:) konfigurace je v souboru /system/astylerc

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • library/bdm/base/loggers.cpp

    r471 r477  
    88#endif 
    99 
    10 namespace bdm{ 
     10namespace bdm { 
    1111void memlog::itsave ( const char* fname ) { 
    1212        it_file itf ( fname ); 
    1313        int i; 
    14         string vec_name=""; 
     14        string vec_name = ""; 
    1515        int istart, iend; 
    16         for ( i=0; i<entries.length();i++ ) { 
    17                 istart=0; 
    18                 for (int j=0; j<entries(i).length(); j++){ // same for as in add!!! 
    19                         vec_name = names(i) + entries(i).name(j); 
    20                         iend=istart+entries(i).size(j)-1; 
    21                         itf << Name ( vec_name ) << vectors ( i ).get_cols(istart,iend); 
     16        for ( i = 0; i < entries.length(); i++ ) { 
     17                istart = 0; 
     18                for ( int j = 0; j < entries ( i ).length(); j++ ) { // same for as in add!!! 
     19                        vec_name = names ( i ) + entries ( i ).name ( j ); 
     20                        iend = istart + entries ( i ).size ( j ) - 1; 
     21                        itf << Name ( vec_name ) << vectors ( i ).get_cols ( istart, iend ); 
    2222                        // move start after current end... 
    23                         istart=iend+1; 
     23                        istart = iend + 1; 
    2424                } 
    25                  
     25 
    2626        } 
    2727} 
    2828 
    29 void memlog::from_setting( const Setting &set )  
    30 {        
     29void memlog::from_setting ( const Setting &set ) { 
    3130        // TODO tady se natvrdo ocekava existence stringu, nejsou zadne defaulty.. je to tak OK? 
    32         string itfilename = (const char*)set["filename"]; 
     31        string itfilename = ( const char* ) set["filename"]; 
    3332        maxlen = set["maxlen"]; 
    3433} 
    3534 
    3635void dirfilelog::init() { 
    37         int i,j,k; 
    38         int nsc=0; 
    39         for ( i=0;i<entries.length();i++ ) {nsc+=entries ( i )._dsize();} 
     36        int i, j, k; 
     37        int nsc = 0; 
     38        for ( i = 0; i < entries.length(); i++ ) { 
     39                nsc += entries ( i )._dsize(); 
     40        } 
    4041        ; //all entries!! 
    4142 
     
    5152        scalarnames.set_length ( nsc ); 
    5253        // For all entries 
    53         int ii=0; 
    54         for ( i=0;i<entries.length();i++ ) { //for entries 
    55                 for ( j=0;j<entries ( i ).length();j++ ) { //for RVs in entries 
     54        int ii = 0; 
     55        for ( i = 0; i < entries.length(); i++ ) { //for entries 
     56                for ( j = 0; j < entries ( i ).length(); j++ ) { //for RVs in entries 
    5657                        int rvsize = entries ( i ).size ( j ); 
    5758                        // for non-empty names 
    58                         if (names(i).length()>0) {scalarnames(ii)=names(i) + "_";} 
     59                        if ( names ( i ).length() > 0 ) { 
     60                                scalarnames ( ii ) = names ( i ) + "_"; 
     61                        } 
    5962                        // add name 
    6063                        scalarnames ( ii ) +=  entries ( i ).name ( j ); 
    6164                        // add number when needed 
    62                         if ( rvsize >1 ) { 
     65                        if ( rvsize > 1 ) { 
    6366                                // copy the same name for th whole RV 
    64                                 for ( k=1;k<rvsize;k++ ) {scalarnames(ii+k)=scalarnames(ii);} 
     67                                for ( k = 1; k < rvsize; k++ ) { 
     68                                        scalarnames ( ii + k ) = scalarnames ( ii ); 
     69                                } 
    6570                                // add numbers 
    66                                 for ( k=0;k<rvsize;k++ ) { //for all scalars in given RV 
    67                                         sprintf ( num,"%d",k ); 
    68                                         scalarnames ( ii ) += (std::string)"_" + num; 
     71                                for ( k = 0; k < rvsize; k++ ) { //for all scalars in given RV 
     72                                        sprintf ( num, "%d", k ); 
     73                                        scalarnames ( ii ) += ( std::string ) "_" + num; 
    6974                                        ii++; 
    7075                                } 
    71                         }  
    72                         else { 
    73                                 ii++;} 
     76                        } else { 
     77                                ii++; 
     78                        } 
    7479                } 
    7580        } 
    7681        //Create format 
    77         string frm="format"; 
     82        string frm = "format"; 
    7883        get_fname ( filename, dirname, frm ); 
    7984 
    8085        FILE* fpf; 
    8186        fpf = fopen ( filename, "w" ); 
    82         for ( i=0;i<ii;i++ ) { 
     87        for ( i = 0; i < ii; i++ ) { 
    8388                fprintf ( fpf, "%s RAW d 1\n", scalarnames ( i ).c_str() ); 
    8489        } 
     
    9499void dirfilelog::write_buffers ( int Len ) { 
    95100        int fp; 
    96         int nen=entries.length(); //all entries!! 
     101        int nen = entries.length(); //all entries!! 
    97102        double *Dt; 
    98103        int DtRows; 
    99         int i,j,k; 
     104        int i, j, k; 
    100105        int ii; //index in scalarnames; 
    101106        int jj; //index in vectors() 
    102107        char filename[200]; 
    103108 
    104         it_assert_debug ( Len<=maxlen,"diffilelog" ); 
     109        it_assert_debug ( Len <= maxlen, "diffilelog" ); 
    105110 
    106111        ii = 0; 
    107         for ( i=0;i<nen;i++ ) { //for entries 
     112        for ( i = 0; i < nen; i++ ) { //for entries 
    108113                Dt = vectors ( i )._data(); 
    109114                DtRows = vectors ( i ).rows(); 
    110115 
    111                 jj=0; 
    112                 for ( j=0;j<entries ( i ).length();j++ ) { //for RVs in entries 
     116                jj = 0; 
     117                for ( j = 0; j < entries ( i ).length(); j++ ) { //for RVs in entries 
    113118                        int rvsize = entries ( i ).size ( j ); 
    114                         for ( k=0;k<rvsize;k++ ) { { //for all scalars in given RV 
    115                                         get_fname ( filename,dirname,scalarnames ( ii ) ); 
    116                                         if ( Len==0 ) //initialization 
     119                        for ( k = 0; k < rvsize; k++ ) { { //for all scalars in given RV 
     120                                        get_fname ( filename, dirname, scalarnames ( ii ) ); 
     121                                        if ( Len == 0 ) //initialization 
    117122                                                fp = open ( filename, O_CREAT | O_WRONLY | O_TRUNC, 00644 ); 
    118123                                        else 
    119124                                                fp = open ( filename, O_CREAT | O_WRONLY | O_APPEND, 00644 ); 
    120125 
    121                                         write ( fp,&Dt[jj* ( DtRows ) ], ( Len ) *sizeof ( double ) ); 
     126                                        write ( fp, &Dt[jj* ( DtRows ) ], ( Len ) *sizeof ( double ) ); 
    122127                                        close ( fp ); 
    123128 
     
    134139void dirfilelog::step ( ) { 
    135140 
    136         if ( ind== ( maxlen -1 ) ) { 
    137                 write_buffers ( ind+1 ); 
     141        if ( ind == ( maxlen - 1 ) ) { 
     142                write_buffers ( ind + 1 ); 
    138143                ind = 0; 
    139         } 
    140         else 
     144        } else 
    141145                ind++; 
    142146 
     
    144148 
    145149void dirfilelog::finalize ( ) { 
    146         if ( ind>0 ) 
     150        if ( ind > 0 ) 
    147151                write_buffers ( ind ); //assuming here that i+1 was not filled 
    148152} 
    149153 
    150154 
    151 void dirfilelog::from_setting( const Setting &set )  
    152 {        
     155void dirfilelog::from_setting ( const Setting &set ) { 
    153156        // TODO tady se natvrdo ocekava existence stringu, nejsou zadne defaulty.. je to tak OK? 
    154         dirname = (const char*)set["dirname"]; 
     157        dirname = ( const char* ) set["dirname"]; 
    155158        maxlen = set["maxlen"]; 
    156         scalarnames.set_length(0); 
     159        scalarnames.set_length ( 0 ); 
    157160} 
    158161