Changeset 959 for library/bdm/bdmroot.h

Show
Ignore:
Timestamp:
05/19/10 11:22:45 (14 years ago)
Author:
mido
Message:

another patch of UI AND L_Levels

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • library/bdm/bdmroot.h

    r950 r959  
    194194}; 
    195195 
    196 //! This class stores the details which will be logged to a logger 
     196//! base class for all log_levels 
    197197//! 
    198 //! This is only the first part of the whole declaration, which has to be however separated into 
    199 //! two different classes for allowing the compilation of source code. For more details 
    200 //! see logger::add_setting(...) method and mainly log_level_template<T>::template<class U> void store( const enum T::log_level_enums log_level_enum, const U data ) const 
    201 //! method. For the reason the second one is templated, it was necessary to declare this whole class.  
    202 template<class T> class log_level_base : public root { 
     198//! the existence of this class is forced by the necessity of passing log_levels to user_info methods, however, the main functionality 
     199//! is located in \c log_level_template class 
     200class log_level_base : public root { 
    203201private: 
    204202        //! this is necessary to allow logger to set ids vector appropriately and also to set registered_logger 
    205203        friend class logger;  
    206  
    207  
    208         //! this method adds new id to its proper position and return the name of this position 
    209         string store_id_and_give_name( enum T::log_level_enums const log_level_enum,  int enum_subindex, int id ) { 
    210                 if( ids(log_level_enum).length() <= enum_subindex ) 
    211                         ids(log_level_enum).set_size( enum_subindex+1, true ); 
    212                 ids(log_level_enum)(enum_subindex) = id;  
    213  
    214                 // here we remove a "log" prefix from name, i.e., for instance it transforms "logevidence" to "evidence" 
    215                 ostringstream stream; 
    216                 string name_with_prefix = names()(log_level_enum); 
    217                 string possible_log_prefix = name_with_prefix.substr(0,3); 
    218                 if( possible_log_prefix == "log" ) 
    219                         stream << name_with_prefix.substr(3,name_with_prefix.length()-3); 
    220                 else  
    221                         stream << name_with_prefix; 
    222  
    223                 // add number to name only in the case there are more registered vectors with the same log_level_enum 
    224                 if( ids(log_level_enum).length() > 1 ) 
    225                         stream << "_" << enum_subindex; 
    226                  
    227                 return stream.str(); 
    228         } 
    229204 
    230205protected: 
     
    237212        Vec<ivec> ids; 
    238213 
    239         //! string equivalents of the used enumerations which are filled with a help of #LOG_LEVEL macro within class T 
    240         const Array<string> &names() const 
    241         { 
    242                 return T::log_level_names(); 
    243         } 
    244214 
    245215        //! default constructor�which is intentionaly declared as protected 
    246216        log_level_base( ) { 
    247217                registered_logger = NULL; 
    248                 int len = names().length(); 
    249                 ids.set_size( len ); 
    250                 for( int i = 0; i<len; i++ ) 
    251                 { 
    252                         ids(i).set_size ( 1 ); 
    253                         ids(i) = -1; 
    254                 } 
    255         } 
    256          
    257 public:  
    258         //! a general utility transforming a comma-separated sequence of strings into an instance of Array<strings> 
    259         static Array<string> string2Array( const string &input ) 
    260         { 
    261                 string result = input; 
    262                 string::size_type loc; 
    263                 while( loc = result.find( ',' ), loc != string::npos ) 
    264                         result[loc] = ' '; 
    265                 return Array<string>("{ " + result + " }" ); 
    266218        } 
    267219};