Changeset 1064 for library/bdm/bdmroot.h

Show
Ignore:
Timestamp:
06/09/10 14:00:40 (14 years ago)
Author:
mido
Message:

astyle applied all over the library

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • library/bdm/bdmroot.h

    r959 r1064  
    2222 
    2323#ifdef MEX 
    24         #include "base/libconfig/lib/libconfig.h++"      
    25         // TODO DODELAT A NAHRADIT #include "base/libconfig_mex.h" 
     24#include "base/libconfig/lib/libconfig.h++" 
     25// TODO DODELAT A NAHRADIT #include "base/libconfig_mex.h" 
    2626#else 
    27         #include "base/libconfig/lib/libconfig.h++" 
     27#include "base/libconfig/lib/libconfig.h++" 
    2828#endif 
    2929 
     
    3434 
    3535namespace bdm { 
    36          
     36 
    3737//! auxiliary function for debugging 
    3838void UI_DBG (const Setting &S, const string &spc, ostream &out ); 
     
    4545class root { 
    4646private: 
    47         //! It is necessary to allow calling of from_setting and to_setting within the UI class ++ i log_options 
    48         friend class UI; 
     47    //! It is necessary to allow calling of from_setting and to_setting within the UI class ++ i log_options 
     48    friend class UI; 
    4949 
    5050protected: 
    5151 
    52         /*!      
    53         \brief Read instance properties according the data stored in the Setting structure. 
    54         It has to be called only through UI class, therefore it is protected  
    55  
    56         At the begining of this method, it is obligatory to call 
    57         the corresponding base::from_setting method. Sometimes, there can be  
    58         an exception from this rule. If so, the programmer is encouraged  
    59         to describe the reasons for this exception in the documentation in detail. 
    60          
    61         Then, all the configuration     components should be read through the UI mechanism.  
    62         Those with UI::SettingPresence set to optional shoud have their defaults fulfilled  
    63         within the body of this method. 
    64  
    65         For instance, declaring a class \c trunk derived from our #root class,  
    66         the implementation of the from_setting method should look like this 
    67  
    68         \code 
    69  
    70         public trunk : public root { 
    71  
    72                 anytype xxx, yyy; 
    73  
    74                 virtual void from_setting ( const Setting &set ) { 
    75                         root::from_setting( set ); 
    76                          
    77                         UI::get ( xxx, set, "xxx", UI::compulsory ); 
    78  
    79                         if ( !UI::get ( yyy, set, "yyy", UI::optional ) ) { 
    80                                 ... // here, it is necessary to set the default of attribute yyy                                                 
    81                         } 
    82  
    83                         ... // another stuff related to trunk class 
    84                 } 
    85  
    86                 ... // other members of this class 
    87         }; 
    88  
    89         \endcode 
    90         */ 
    91         virtual void from_setting ( const Setting &set ) { 
    92         } 
    93  
    94         /*!      
    95         \brief  Save all the instance properties into the Setting structure. 
    96         It has to be called only through UI class, therefore it is protected  
    97  
    98         The only obligatory rule concerning the body of this method is to call 
    99         the corresponding base::to_setting method first.        Sometimes, there can  
    100         be an exception from this rule. If so, the programmer is encouraged  
    101         to describe the reasons for this exception in the documentation in detail. 
    102          
    103         For instance, declaring 
    104         a class \c trunk derived from our #root class, the implementation of  
    105         the to_setting method should look like this 
    106  
    107         \code 
    108         public trunk : public root { 
    109  
    110                 anytype xxx; 
    111  
    112                 virtual void to_setting ( const Setting &set ) { 
    113                         root::to_setting( set ); 
    114  
    115                         UI::save ( xxx, set, "xxx" ); 
    116                          
    117                         ... // another stuff related directly to trunk class 
    118  
    119                 } 
    120  
    121                 ... // other members of this class 
    122  
    123         }; 
    124  
    125         \endcode 
    126         */ 
    127         virtual void to_setting ( Setting &set ) const { 
    128         } 
     52    /*! 
     53    \brief Read instance properties according the data stored in the Setting structure. 
     54    It has to be called only through UI class, therefore it is protected 
     55 
     56    At the begining of this method, it is obligatory to call 
     57    the corresponding base::from_setting method. Sometimes, there can be 
     58    an exception from this rule. If so, the programmer is encouraged 
     59    to describe the reasons for this exception in the documentation in detail. 
     60 
     61    Then, all the configuration components should be read through the UI mechanism. 
     62    Those with UI::SettingPresence set to optional shoud have their defaults fulfilled 
     63    within the body of this method. 
     64 
     65    For instance, declaring a class \c trunk derived from our #root class, 
     66    the implementation of the from_setting method should look like this 
     67 
     68    \code 
     69 
     70    public trunk : public root { 
     71 
     72        anytype xxx, yyy; 
     73 
     74        virtual void from_setting ( const Setting &set ) { 
     75                root::from_setting( set ); 
     76 
     77                UI::get ( xxx, set, "xxx", UI::compulsory ); 
     78 
     79                if ( !UI::get ( yyy, set, "yyy", UI::optional ) ) { 
     80                        ... // here, it is necessary to set the default of attribute yyy 
     81                } 
     82 
     83                ... // another stuff related to trunk class 
     84        } 
     85 
     86        ... // other members of this class 
     87    }; 
     88 
     89    \endcode 
     90    */ 
     91    virtual void from_setting ( const Setting &set ) { 
     92    } 
     93 
     94    /*! 
     95    \brief      Save all the instance properties into the Setting structure. 
     96    It has to be called only through UI class, therefore it is protected 
     97 
     98    The only obligatory rule concerning the body of this method is to call 
     99    the corresponding base::to_setting method first.    Sometimes, there can 
     100    be an exception from this rule. If so, the programmer is encouraged 
     101    to describe the reasons for this exception in the documentation in detail. 
     102 
     103    For instance, declaring 
     104    a class \c trunk derived from our #root class, the implementation of 
     105    the to_setting method should look like this 
     106 
     107    \code 
     108    public trunk : public root { 
     109 
     110        anytype xxx; 
     111 
     112        virtual void to_setting ( const Setting &set ) { 
     113                root::to_setting( set ); 
     114 
     115                UI::save ( xxx, set, "xxx" ); 
     116 
     117                ... // another stuff related directly to trunk class 
     118 
     119        } 
     120 
     121        ... // other members of this class 
     122 
     123    }; 
     124 
     125    \endcode 
     126    */ 
     127    virtual void to_setting ( Setting &set ) const { 
     128    } 
    129129 
    130130public: 
    131          
    132         //!default constructor 
    133         root() {}; 
    134  
    135         //! make sure this is a virtual object 
    136         virtual ~root() { 
    137         } 
    138  
    139         //! Returns basic textual info about the current instance 
    140         virtual string to_string() const { 
    141                 Config C; 
    142                 Setting &set=C.getRoot(); 
    143                 this->to_setting(set); 
    144                 ostringstream os; 
    145                 UI_DBG(set, "", os); 
    146                 return os.str(); 
    147         } 
    148         //! Register log levels of each inheritance layer to a logger, i.e. allocate space for data from this class 
    149         virtual void log_register ( logger &L, const string &prefix ) { 
    150         } 
    151  
    152         //! Write current information into the given logger 
    153         virtual void log_write() const { 
    154         }  
    155  
    156         /*!      
    157         \brief  This method checks that all internal structures has been set up correctly. 
    158  
    159         It is called automatically after the call of the #from_setting method by the mechanism of the UI class.  
    160         However, it can be called in any other situation to assure the correctness of an instance. 
    161          
    162         The only obligatory rule concerning the body of this method is to call 
    163         the corresponding base::validate method first. Sometimes, there can be  
    164         an exception from this rule. If so, the programmer is encouraged  
    165         to describe the reasons for this exception in the documentation in detail.       
    166          
    167         Then, only those checks which are not implemented in the base method  
    168         are implemented here. For instance, declaring a class \c trunk derived from our  
    169         #root class, the implementation of the method validate should  
    170         look like this 
    171  
    172         \code 
    173         public trunk : public root { 
    174  
    175                 virtual void validate ( ) { 
    176                         root::validate( ); 
    177  
    178                         ... // checks related directly to trunk class 
    179                 } 
    180  
    181                 ... // other members of this class 
    182  
    183         }; 
    184  
    185         \endcode 
    186  
    187         */ 
    188         virtual void validate() { 
    189         } 
    190  
    191         //! Virtual method providing deep copy of instances 
    192         virtual root* _copy() const NOT_IMPLEMENTED(NULL); 
    193          
     131 
     132    //!default constructor 
     133    root() {}; 
     134 
     135    //! make sure this is a virtual object 
     136    virtual ~root() { 
     137    } 
     138 
     139    //! Returns basic textual info about the current instance 
     140    virtual string to_string() const { 
     141        Config C; 
     142        Setting &set=C.getRoot(); 
     143        this->to_setting(set); 
     144        ostringstream os; 
     145        UI_DBG(set, "", os); 
     146        return os.str(); 
     147    } 
     148    //! Register log levels of each inheritance layer to a logger, i.e. allocate space for data from this class 
     149    virtual void log_register ( logger &L, const string &prefix ) { 
     150    } 
     151 
     152    //! Write current information into the given logger 
     153    virtual void log_write() const { 
     154    } 
     155 
     156    /*! 
     157    \brief      This method checks that all internal structures has been set up correctly. 
     158 
     159    It is called automatically after the call of the #from_setting method by the mechanism of the UI class. 
     160    However, it can be called in any other situation to assure the correctness of an instance. 
     161 
     162    The only obligatory rule concerning the body of this method is to call 
     163    the corresponding base::validate method first. Sometimes, there can be 
     164    an exception from this rule. If so, the programmer is encouraged 
     165    to describe the reasons for this exception in the documentation in detail. 
     166 
     167    Then, only those checks which are not implemented in the base method 
     168    are implemented here. For instance, declaring a class \c trunk derived from our 
     169    #root class, the implementation of the method validate should 
     170    look like this 
     171 
     172    \code 
     173    public trunk : public root { 
     174 
     175        virtual void validate ( ) { 
     176                root::validate( ); 
     177 
     178                ... // checks related directly to trunk class 
     179        } 
     180 
     181        ... // other members of this class 
     182 
     183    }; 
     184 
     185    \endcode 
     186 
     187    */ 
     188    virtual void validate() { 
     189    } 
     190 
     191    //! Virtual method providing deep copy of instances 
     192    virtual root* _copy() const NOT_IMPLEMENTED(NULL); 
     193 
    194194}; 
    195195 
     
    200200class log_level_base : public root { 
    201201private: 
    202         //! this is necessary to allow logger to set ids vector appropriately and also to set registered_logger 
    203         friend class logger;  
     202    //! this is necessary to allow logger to set ids vector appropriately and also to set registered_logger 
     203    friend class logger; 
    204204 
    205205protected: 
    206         //! internal pointer to the logger to which this log_level is registered 
    207         //!  
    208         //! it is set to NULL at the beginning 
    209         logger * registered_logger; 
    210                  
    211         //! vector of vectors of log IDs - one element for each entry and multiple entries can be stored on the position of one enum 
    212         Vec<ivec> ids; 
    213  
    214  
    215         //! default constructor�which is intentionaly declared as protected 
    216         log_level_base( ) { 
    217                 registered_logger = NULL; 
    218         } 
     206    //! internal pointer to the logger to which this log_level is registered 
     207    //! 
     208    //! it is set to NULL at the beginning 
     209    logger * registered_logger; 
     210 
     211    //! vector of vectors of log IDs - one element for each entry and multiple entries can be stored on the position of one enum 
     212    Vec<ivec> ids; 
     213 
     214 
     215    //! default constructor�which is intentionaly declared as protected 
     216    log_level_base( ) { 
     217        registered_logger = NULL; 
     218    } 
    219219}; 
    220220//UIREGISTER IS FORBIDDEN FOR THIS CLASS,  AS IT SHOULD BE LOADED ONLY THROUGH THE SPECIALIZED UI::GET(...) METHOD