root/library/bdm/bdmroot.h @ 676

Revision 676, 2.2 kB (checked in by smidl, 15 years ago)

logger refactoring

Line 
1
2/*!
3  \file
4  \brief Bayesian Models (bm) that use Bayes rule to learn from observations
5  \author Vaclav Smidl.
6
7  -----------------------------------
8  BDM++ - C++ library for Bayesian Decision Making under Uncertainty
9
10  Using IT++ for numerical operations
11  -----------------------------------
12*/
13
14#ifndef root_H
15#define root_H
16
17#include <string>
18
19#include "itpp_ext.h"
20#include "base/libconfig/libconfig.h++"
21
22using namespace libconfig;
23using namespace itpp;
24using namespace std;
25
26namespace bdm {
27       
28//forward declaration
29class logger;
30       
31//! information about connection to a logger
32class log_record {
33public:
34        //!remember which logger is registered
35        logger &L;
36        //! vector of log IDs - one element for each entry
37        ivec ids;
38       
39        //!default constructor
40        log_record(logger &L0): L(L0),ids(0){}
41};
42       
43//! Root class of BDM objects
44class root {
45        protected:
46        //! record of connections to the logger
47        log_record* logrec;
48        //! level of details that will be logged to a logger
49        int log_level;
50       
51public:
52        //!default constructor
53        root() : logrec(NULL),log_level(0) {};
54       
55        //! make sure this is a virtual object
56        virtual ~root() {
57                if (logrec) delete logrec;
58        }
59
60        //! Returns a basic textual info about the current instance
61        virtual string to_string() const {
62                return "";
63        }
64        //! Register itself in a logger, i.e. allocate space for data from this class
65        //! The level of details (parameter \c level ) is individual for each class.
66        virtual void log_register(logger &L, const string &prefix){
67                logrec = new log_record(L);
68        }
69       
70        //! Write current information into the given logger
71        virtual void log_write() const {
72        }
73        //! set level of details to be logged - needs to be called before log_register!
74        virtual void set_log_level(int level) {log_level = level;}
75
76        //! Read instance properties according the data stored in the Setting structure
77        virtual void from_setting ( const Setting &set ) {
78        }
79
80        //! Save all the instance properties into the Setting structure
81        virtual void to_setting ( Setting &set ) const {
82        }
83
84        //! Check that all internal structures has been correctly set-up. Called at the end of from_setting.
85        virtual void validate() {
86        }
87       
88};
89
90}; //namespace
91#endif // root_H
Note: See TracBrowser for help on using the browser.