| 20 | | |
| 21 | | /*! |
| 22 | | @brief Class for storing results (and semi-results) of an experiment |
| 23 | | |
| 24 | | This class abstracts logging of results from implementation. This class replaces direct logging of results (e.g. to files or to global variables) by calling methods of a logger. Specializations of this abstract class for specific storage method are designed. |
| 25 | | */ |
| 26 | | class logger : public bdmroot{ |
| 27 | | protected: |
| 28 | | //! RVs of all logged variables. |
| 29 | | Array<RV> entries; |
| 30 | | //! Names of logged quantities, e.g. names of algorithm variants |
| 31 | | Array<string> names; |
| 32 | | public: |
| 33 | | //!Default constructor |
| 34 | | logger ( ) : entries(0),names ( 0 ) {} |
| 35 | | |
| 36 | | //! returns an identifier which will be later needed for calling the log() function |
| 37 | | virtual int add (const RV &rv, string name="" ) { |
| 38 | | int id=entries.length(); |
| 39 | | names=concat ( names, name ); // diff |
| 40 | | entries.set_length(id+1,true); |
| 41 | | entries(id)= rv; |
| 42 | | return id; // identifier of the last entry |
| 43 | | } |
| 44 | | |
| 45 | | //! log this vector |
| 46 | | virtual void logit ( int id, const vec &v ) =0; |
| 47 | | |
| 48 | | //! Shifts storage position for another time step. |
| 49 | | virtual void step() =0; |
| 50 | | |
| 51 | | //! Finalize storing information |
| 52 | | virtual void finalize() {}; |
| 53 | | |
| 54 | | //! Initialize the storage |
| 55 | | virtual void init(){}; |
| 56 | | |
| 57 | | //! for future use |
| 58 | | virtual ~logger() {}; |
| 59 | | }; |
| 60 | | |