Changeset 789 for library/bdm/bdmroot.h

Show
Ignore:
Timestamp:
01/18/10 20:42:46 (14 years ago)
Author:
mido
Message:

libconfig_mex.cpp and libconfig_mex.h added (but that is all is done at the moment)
the documentation of root::to_setting(), root::from_setting() and root::validate() was extended

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • library/bdm/bdmroot.h

    r769 r789  
    1818 
    1919#include "itpp_ext.h" 
    20 #include "base/libconfig/lib/libconfig.h++" 
    2120#include "bdmerror.h" 
     21 
     22#ifdef MEX 
     23        #include "base/libconfig/lib/libconfig.h++"      
     24        // TODO DODELAT A NAHRADIT #include "base/libconfig_mex.h" 
     25#else 
     26        #include "base/libconfig/lib/libconfig.h++" 
     27#endif 
     28 
    2229 
    2330using namespace libconfig; 
     
    2633 
    2734namespace bdm { 
    28  
    29          
    30         //! auxiliary function for debugging 
    31         void UI_DBG (const Setting &S, const string &spc, ostream &out ); 
     35         
     36//! auxiliary function for debugging 
     37void UI_DBG (const Setting &S, const string &spc, ostream &out ); 
    3238         
    3339//forward declaration 
     
    5460        int log_level; 
    5561 
    56         //! It is necessary to allow calling of from_setting and to_setting within the user_info class 
     62        //! It is necessary to allow calling of from_setting and to_setting within the UI class 
    5763        friend class UI; 
    5864 
    59         //! Read instance properties according the data stored in the Setting structure 
    60         //!  
    61         //! It has to be called only through user_info class, therefore it is protected  
     65        /*!      
     66        \brief Read instance properties according the data stored in the Setting structure. 
     67        It has to be called only through UI class, therefore it is protected  
     68 
     69        At the begining of this method, it is obligatory to call 
     70        the corresponding base::from_setting method. Sometimes, there can be  
     71        an exception from this rule. If so, the programmer is encouraged  
     72        to describe the reasons for this exception in the documentation in detail. 
     73         
     74        Then, all the configuration     components should be read through the UI mechanism.  
     75        Those with UI::SettingPresence set to optional shoud have their defaults fulfilled  
     76        within the body of this method. 
     77 
     78        For instance, declaring a class \c trunk derived from our #root class,  
     79        the implementation of the from_setting method should look like this 
     80 
     81        \code 
     82 
     83        public trunk : public root { 
     84 
     85                anytype xxx, yyy; 
     86 
     87                virtual void from_setting ( const Setting &set ) { 
     88                        root::from_setting( set ); 
     89                         
     90                        UI::get ( xxx, set, "xxx", UI::compulsory ); 
     91 
     92                        if ( !UI::get ( yyy, set, "yyy", UI::optional ) ) { 
     93                                ... // here, it is necessary to set the default of attribute yyy                                                 
     94                        } 
     95 
     96                        ... // another stuff related to trunk class 
     97                } 
     98 
     99                ... // other members of this class 
     100        }; 
     101 
     102        \endcode 
     103        */ 
    62104        virtual void from_setting ( const Setting &set ) { 
    63105        } 
    64106 
    65         //! Save all the instance properties into the Setting structure 
    66         //! 
    67         //! It has to be called only through user_info class, therefore it is protected  
     107        /*!      
     108        \brief  Save all the instance properties into the Setting structure. 
     109        It has to be called only through UI class, therefore it is protected  
     110 
     111        The only obligatory rule concerning the body of this method is to call 
     112        the corresponding base::to_setting method first.        Sometimes, there can  
     113        be an exception from this rule. If so, the programmer is encouraged  
     114        to describe the reasons for this exception in the documentation in detail. 
     115         
     116        For instance, declaring 
     117        a class \c trunk derived from our #root class, the implementation of  
     118        the to_setting method should look like this 
     119 
     120        \code 
     121        public trunk : public root { 
     122 
     123                anytype xxx; 
     124 
     125                virtual void to_setting ( const Setting &set ) { 
     126                        root::to_setting( set ); 
     127 
     128                        UI::save ( xxx, set, "xxx" ); 
     129                         
     130                        ... // another stuff related directly to trunk class 
     131 
     132                } 
     133 
     134                ... // other members of this class 
     135 
     136        }; 
     137 
     138        \endcode 
     139        */ 
    68140        virtual void to_setting ( Setting &set ) const { 
    69141        } 
     
    101173        } 
    102174 
    103         //! Check that all internal structures has been correctly set-up. Called at the end of from_setting. 
     175        /*!      
     176        \brief  This method checks that all internal structures has been set up correctly. 
     177 
     178        It is called automatically after the call of the #from_setting method by the mechanism of the UI class.  
     179        However, it can be called in any other situation to assure the correctness of an instance. 
     180         
     181        The only obligatory rule concerning the body of this method is to call 
     182        the corresponding base::validate method first. Sometimes, there can be  
     183        an exception from this rule. If so, the programmer is encouraged  
     184        to describe the reasons for this exception in the documentation in detail.       
     185         
     186        Then, only those checks which are not implemented in the base method  
     187        are implemented here. For instance, declaring a class \c trunk derived from our  
     188        #root class, the implementation of the method validate should  
     189        look like this 
     190 
     191        \code 
     192        public trunk : public root { 
     193 
     194                virtual void validate ( ) { 
     195                        root::validate( ); 
     196 
     197                        ... // checks related directly to trunk class 
     198                } 
     199 
     200                ... // other members of this class 
     201 
     202        }; 
     203 
     204        \endcode 
     205 
     206        */ 
    104207        virtual void validate() { 
    105208        } 
     
    108211        virtual root* _copy() const NOT_IMPLEMENTED(NULL); 
    109212         
    110  
    111213        //! access function 
    112214        int _log_level() const { 
    113215                return log_level; 
    114216        } 
    115  
    116217}; 
    117218