Changeset 676 for library/bdm/bdmroot.h

Show
Ignore:
Timestamp:
10/22/09 01:13:47 (15 years ago)
Author:
smidl
Message:

logger refactoring

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • library/bdm/bdmroot.h

    r673 r676  
     1 
    12/*! 
    23  \file 
     
    2425 
    2526namespace bdm { 
    26  
     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         
    2743//! Root class of BDM objects 
    2844class root { 
    2945        protected: 
    30         //! level of details that will be logged to logger 
     46        //! record of connections to the logger 
     47        log_record* logrec; 
     48        //! level of details that will be logged to a logger 
    3149        int log_level; 
    32         //! vector of log IDs - one element for each entry 
    33         ivec log_ids; 
     50         
    3451public: 
     52        //!default constructor 
     53        root() : logrec(NULL),log_level(0) {}; 
     54         
    3555        //! make sure this is a virtual object 
    3656        virtual ~root() { 
     57                if (logrec) delete logrec; 
    3758        } 
    3859 
    39         //! This method returns a basic info about the current instance 
     60        //! Returns a basic textual info about the current instance 
    4061        virtual string to_string() const { 
    4162                return ""; 
    4263        } 
     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;} 
    4375 
    44         //! This method arrange instance properties according the data stored in the Setting structure 
     76        //! Read instance properties according the data stored in the Setting structure 
    4577        virtual void from_setting ( const Setting &set ) { 
    4678        } 
    4779 
    48         //! This method save all the instance properties into the Setting structure 
     80        //! Save all the instance properties into the Setting structure 
    4981        virtual void to_setting ( Setting &set ) const { 
    5082        } 
    5183 
    52         //! This method checks that all internal structures has been correctly set-up, always call at the ned of from_setting 
     84        //! Check that all internal structures has been correctly set-up. Called at the end of from_setting. 
    5385        virtual void validate() { 
    5486        } 
     87         
    5588}; 
    5689