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

- File List
- File Members

# 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         string itfilename;
    00038 public:
    00040         memlog ( int maxlen0, string itf="" ) : logger(),maxlen ( maxlen0 ),ind ( 0 ),vectors ( 0 ),itfilename(itf) {}
    00042         void init() {
    00043                 int i; int n =entries.length();
    00044                 vectors.set_size ( n );
    00045                 for ( i=0;i<n;i++ ) {vectors(i).set_size (maxlen,entries(i)._dsize() );}
    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                 if(id>=0){ vectors ( id ).set_row ( ind,v );}
    00051         }
    00052         void logit ( int id, const double &d ) {
    00053                 it_assert_debug(id<vectors.length(),"Logger was not initialized, run init().");
    00054                 it_assert_debug(vectors(id).cols()==1,"Vector expected");
    00055                 if(id>=0){ vectors ( id ) ( ind )=d;}
    00056         }
    00058         void itsave(const char* fname);
    00060         void finalize() {if (itfilename.length()>0) itsave(itfilename.c_str());};
    00061
    00062 };
    00063
    00072 class dirfilelog : public memlog {
    00073
    00074 protected:
    00076         string dirname;
    00078         Array<string> scalarnames;
    00079 public:
    00083         dirfilelog ( std::string dirname0, int maxlen0 ) : memlog ( maxlen0 ), dirname ( dirname0 ), scalarnames ( 0 ) {}
    00085         void init();
    00086         void step();
    00087         void finalize();
    00091         void write_buffers ( int Len );
    00092 };
    00093
    00094 };
    00095 #endif // LGR_H