- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

# loggers.h

Go to the documentation of this file.

    00001
    00013 #ifndef LGR_H
    00014 #define LGR_H
    00015
    00016 #include "libBM.h"
    00017
    00018 namespace bdm{
    00019 using std::string;
    00020
    00027 class memlog : public logger {
    00028
    00029 protected:
    00031         int maxlen;
    00033         int ind;
    00035         Array<mat> vectors;
    00037 public:
    00039         memlog ( int maxlen0 ) : logger(),maxlen ( maxlen0 ),ind ( 0 ),vectors ( 0 ) {}
    00041         void init() {
    00042                 int i; int n =entries.length();
    00043                 vectors.set_size ( n );
    00044                 for ( i=0;i<n;i++ ) {vectors(i).set_size (maxlen,entries(i)._dsize() );}
    00045                 ;
    00046         }
    00047         void step() {if ( ind<maxlen ) ind++; else it_error ( "memlog::ind is too high;" );}
    00048         void logit ( int id, const vec &v ) {
    00049                 it_assert_debug(id<vectors.length(),"Logger was not initialized, run init().");
    00050                 vectors ( id ).set_row ( ind,v );}
    00052         void itsave(const char* fname);
    00053 };
    00054
    00063 class dirfilelog : public memlog {
    00064
    00065 protected:
    00067         string dirname;
    00069         Array<string> scalarnames;
    00070 public:
    00074         dirfilelog ( std::string dirname0, int maxlen0 ) : memlog ( maxlen0 ), dirname ( dirname0 ), scalarnames ( 0 ) {}
    00076         void init();
    00077         void step();
    00078         void finalize();
    00082         void write_buffers ( int Len );
    00083 };
    00084
    00085 };
    00086 #endif // LGR_H