root/library/bdm/bdmroot.h @ 756

Revision 756, 2.5 kB (checked in by mido, 14 years ago)

odladen FindMatlab?.cmake
trida UImxConfig smazana a nahrazena statickou funkci UImxArray::create_mxArray(), a podle toho upravene zdrojaky
odstranen abort ze shared pointeru

  • Property svn:eol-style set to native
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/lib/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 {
45protected:
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
51        //! It is necessary to allow calling of from_setting and to_setting within the user_info class
52        friend class UI;
53
54        //! Read instance properties according the data stored in the Setting structure
55        //!
56        //! It has to be called only through user_info class, therefore it is protected
57        virtual void from_setting ( const Setting &set ) {
58        }
59
60        //! Save all the instance properties into the Setting structure
61        //!
62        //! It has to be called only through user_info class, therefore it is protected
63        virtual void to_setting ( Setting &set ) const {
64        }
65
66public:
67        //!default constructor
68        root() : logrec ( NULL ), log_level ( 0 ) {};
69
70        //! make sure this is a virtual object
71        virtual ~root() {
72                if ( logrec ) delete logrec;
73        }
74
75        //! Returns a basic textual info about the current instance
76        virtual string to_string() const {
77                return "";
78        }
79        //! Register itself in a logger, i.e. allocate space for data from this class
80        //! The level of details (parameter \c level ) is individual for each class.
81        virtual void log_register ( logger &L, const string &prefix ) {
82                logrec = new log_record ( L );
83        }
84
85        //! Write current information into the given logger
86        virtual void log_write() const {
87        }
88        //! set level of details to be logged - needs to be called before log_register!
89        virtual void set_log_level ( int level ) {
90                log_level = level;
91        }
92
93        //! Check that all internal structures has been correctly set-up. Called at the end of from_setting.
94        virtual void validate() {
95        }
96        //! access function
97        int _log_level() const {
98                return log_level;
99        }
100
101};
102
103}; //namespace
104#endif // root_H
Note: See TracBrowser for help on using the browser.