Changeset 850 for library/bdm/bdmroot.h

Show
Ignore:
Timestamp:
03/04/10 16:41:30 (14 years ago)
Author:
smidl
Message:

changes in Loggers!

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • library/bdm/bdmroot.h

    r789 r850  
    1616 
    1717#include <string> 
     18#include <bitset> 
    1819 
    1920#include "itpp_ext.h" 
     
    3738void UI_DBG (const Setting &S, const string &spc, ostream &out ); 
    3839         
     40 
     41//! level of details that will be logged to a logger 
     42// DULEZITE TODO - zde musi respektovat aktualne ulozene hodnoty, tj. nacist je, pak pridat 
     43// ty co se maji v tomto kroku ulozit a pak vse ulozit.. protoze to delame kompozici a ne dedenim  DODELAT 
     44// ALE HOUBY, TAKHLE TO NEJDE, musime nechat jako samostatny objekt, kazda uroven tedy zvlast,  
     45// jednoznacne jmeno atd..  
     46// 
     47//! information about connection to a logger 
     48template<class T> class logged_options { 
     49private: 
     50        friend class UI; 
     51 
     52        //! boolean flags related indicating which details will be logged to a logger 
     53        bitset<32> values; 
     54 
     55        virtual const Array<string> &names() const 
     56        { 
     57                return T::__option_names(); 
     58        } 
     59 
     60public: 
     61         
     62        bool any() const 
     63        { 
     64                return values.any(); 
     65        } 
     66 
     67        bool operator [] (const enum T::possible_options &option ) const 
     68        { 
     69                return values[option]; 
     70        } 
     71 
     72        bitset<32>::reference operator [] (const enum T::possible_options &option ) 
     73        { 
     74                return values[option]; 
     75        } 
     76}; 
     77 
     78// MUZEME INTERNE POUZIVAT ENUMY, A KLIDNE MENIT JEJICH PORADI, DIKY TOMUHLE MAKRU SE VZDY NAMAPUJI NA TY SPRAVNE STRINGY  
     79#define LOG_LEVEL(CLASSNAME,...) private: friend class logged_options<CLASSNAME>; static const Array<string> &__option_names() { static const Array<string> option_names( "{"#__VA_ARGS__"}" ); return option_names; }; public: enum possible_options { __VA_ARGS__ }; logged_options<CLASSNAME> log_level; 
     80 
    3981//forward declaration 
    4082class logger; 
     
    5799        //! record of connections to the logger 
    58100        log_record* logrec; 
    59         //! level of details that will be logged to a logger 
    60         int log_level; 
    61101 
    62102        //! It is necessary to allow calling of from_setting and to_setting within the UI class 
     
    142182 
    143183public: 
     184        enum possible_options{}; 
    144185        //!default constructor 
    145         root() : logrec ( NULL ), log_level ( 0 ) {}; 
     186        root() : logrec ( NULL ) {}; 
    146187 
    147188        //! make sure this is a virtual object 
     
    168209        virtual void log_write() const { 
    169210        } 
    170         //! set level of details to be logged - needs to be called before log_register! 
    171         virtual void set_log_level ( int level ) { 
    172                 log_level = level; 
    173         } 
    174211 
    175212        /*!      
     
    211248        virtual root* _copy() const NOT_IMPLEMENTED(NULL); 
    212249         
    213         //! access function 
    214         int _log_level() const { 
    215                 return log_level; 
    216         } 
    217250}; 
    218251