[676] | 1 | |
---|
[357] | 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 | |
---|
[390] | 14 | #ifndef root_H |
---|
| 15 | #define root_H |
---|
[357] | 16 | |
---|
| 17 | #include <string> |
---|
| 18 | |
---|
| 19 | #include "itpp_ext.h" |
---|
[691] | 20 | #include "base/libconfig/lib/libconfig.h++" |
---|
[357] | 21 | |
---|
| 22 | using namespace libconfig; |
---|
| 23 | using namespace itpp; |
---|
| 24 | using namespace std; |
---|
| 25 | |
---|
| 26 | namespace bdm { |
---|
[676] | 27 | |
---|
| 28 | //forward declaration |
---|
| 29 | class logger; |
---|
| 30 | |
---|
| 31 | //! information about connection to a logger |
---|
| 32 | class log_record { |
---|
| 33 | public: |
---|
| 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 | |
---|
[357] | 43 | //! Root class of BDM objects |
---|
[390] | 44 | class root { |
---|
[673] | 45 | protected: |
---|
[676] | 46 | //! record of connections to the logger |
---|
| 47 | log_record* logrec; |
---|
| 48 | //! level of details that will be logged to a logger |
---|
[669] | 49 | int log_level; |
---|
[676] | 50 | |
---|
[357] | 51 | public: |
---|
[676] | 52 | //!default constructor |
---|
| 53 | root() : logrec(NULL),log_level(0) {}; |
---|
| 54 | |
---|
[357] | 55 | //! make sure this is a virtual object |
---|
[408] | 56 | virtual ~root() { |
---|
[676] | 57 | if (logrec) delete logrec; |
---|
[357] | 58 | } |
---|
| 59 | |
---|
[676] | 60 | //! Returns a basic textual info about the current instance |
---|
[665] | 61 | virtual string to_string() const { |
---|
[357] | 62 | return ""; |
---|
| 63 | } |
---|
[676] | 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;} |
---|
[357] | 75 | |
---|
[676] | 76 | //! Read instance properties according the data stored in the Setting structure |
---|
[477] | 77 | virtual void from_setting ( const Setting &set ) { |
---|
[357] | 78 | } |
---|
| 79 | |
---|
[676] | 80 | //! Save all the instance properties into the Setting structure |
---|
[477] | 81 | virtual void to_setting ( Setting &set ) const { |
---|
[357] | 82 | } |
---|
| 83 | |
---|
[676] | 84 | //! Check that all internal structures has been correctly set-up. Called at the end of from_setting. |
---|
[408] | 85 | virtual void validate() { |
---|
[357] | 86 | } |
---|
[676] | 87 | |
---|
[357] | 88 | }; |
---|
| 89 | |
---|
| 90 | }; //namespace |
---|
[390] | 91 | #endif // root_H |
---|