Changeset 493

Show
Ignore:
Timestamp:
08/11/09 08:32:02 (15 years ago)
Author:
vbarta
Message:

fixed UIREGISTER

Location:
library
Files:
13 modified

Legend:

Unmodified
Added
Removed
  • library/bdm/base/user_info.cpp

    r490 r493  
    6363 
    6464void UI::MappedUI::add_class ( const string &class_name, const type_info * const class_type_info, const UI* const ui ) { 
    65         pair< const string, const UI* const > new_pair = make_pair ( class_name, ui ); 
    66         mapped_strings().insert ( new_pair ); 
    67         mapped_type_infos().insert ( make_pair ( class_type_info, new_pair.first ) ); 
     65        pair< StringToUIMap::iterator, bool> inres = 
     66                mapped_strings().insert ( 
     67                        StringToUIMap::value_type( class_name, ui ) ); 
     68        if ( inres.second ) { 
     69                mapped_type_infos().insert ( 
     70                        TypeInfoToStringMap::value_type ( 
     71                                class_type_info, class_name ) ); 
     72        } 
    6873} 
    6974 
  • library/bdm/base/user_info.h

    r483 r493  
    514514 
    515515 
    516 //! The only UI descendant class which is not intended for direct use. It should be accessed within the ::UIREGISTER macro only. 
     516//! The only UI descendant class which is not intended for direct use. It should be accessed within the UIREGISTER macro only. 
    517517//! \ref ui_page 
    518518template<typename T> class ParticularUI : private UI { 
    519 private: 
    520         //! Default constructor, which is intentionally declared as private 
     519public: 
     520        //! Constructor used by the UIREGISTER macro. 
    521521        ParticularUI<T> ( const string &class_name ) : UI ( class_name, &typeid ( T ) ) {}; 
    522  
    523 public: 
    524         //! The only instance of this class (each type T has its own instance) which is used as a factory for processing related UI 
    525         static const ParticularUI<T>& factory; 
    526522 
    527523        //! A method returning a brand new instance of class T, this method is the reason why there have to be a parameterless construcotor in class T 
     
    533529} 
    534530 
     531#define CONCATENATE0( name, line ) name##line 
     532#define CONCATENATE( name, line ) CONCATENATE0( name, line ) 
     533 
    535534/*! 
    536535  \def UIREGISTER(class_name) 
     
    543542*/ 
    544543#ifndef BDMLIB 
    545 #define UIREGISTER(class_name) template<> const ParticularUI<class_name>& ParticularUI<class_name>::factory = ParticularUI<class_name>(#class_name) 
     544#define UIREGISTER(class_name) static ParticularUI<class_name> CONCATENATE(registrator, __LINE__)(#class_name) 
    546545#else 
    547546#define UIREGISTER(class_name) 
  • library/tests/datalink_test.cpp

    r477 r493  
    1 #define BDMLIB // not an ideal way to prevent double registration of UI factories... 
    21#include "../bdm/stat/exp_family.h" 
    32#include "UnitTest++.h" 
  • library/tests/egiw_harness.h

    r477 r493  
    2929        void from_setting ( const Setting &set ); 
    3030}; 
     31UIREGISTER(egiw_harness); 
    3132 
    3233} 
  • library/tests/egiw_test.cpp

    r477 r493  
    1 #define BDMLIB // not an ideal way to prevent double registration of UI factories... 
    21#include "base/bdmbase.h" 
    32#include "base/user_info.h" 
     
    1211 
    1312using namespace bdm; 
    14  
    15 template<> 
    16 const ParticularUI<egiw> &ParticularUI<egiw>::factory ( 
    17     ParticularUI<egiw> ( "egiw" ) ); 
    18  
    19 template<> 
    20 const ParticularUI<egiw_harness> &ParticularUI<egiw_harness>::factory ( 
    21     ParticularUI<egiw_harness> ( "egiw_harness" ) ); 
    2213 
    2314TEST ( test_egiw ) { 
  • library/tests/epdf_harness.cpp

    r489 r493  
    1010namespace bdm { 
    1111 
    12 template<> 
    13 const ParticularUI<epdf_harness> &ParticularUI<epdf_harness>::factory ( 
    14     ParticularUI<epdf_harness> ( "epdf_harness" ) ); 
    15  
    1612void epdf_harness::test_config ( const char *config_file_name ) { 
    1713        RV::clear_all(); 
  • library/tests/epdf_harness.h

    r482 r493  
    1313#ifndef EPDF_HARNESS_H 
    1414#define EPDF_HARNESS_H 
    15  
    16 #define BDMLIB // not an ideal way to prevent double registration of UI factories... 
    1715 
    1816#include "bdmroot.h" 
     
    7674        void check_cond_covariance( mprod &mep ); 
    7775}; 
     76UIREGISTER(epdf_harness); 
    7877 
    7978} 
  • library/tests/epdf_test.cpp

    r477 r493  
    1 #define BDMLIB // not an ideal way to prevent double registration of UI factories... 
    21#include "base/user_info.h" 
    32#include "stat/exp_family.h" 
     
    65 
    76using namespace bdm; 
    8  
    9 template<> 
    10 const ParticularUI<egamma> &ParticularUI<egamma>::factory ( 
    11     ParticularUI<egamma> ( "egamma" ) ); 
    12  
    13 template<> 
    14 const ParticularUI<enorm<ldmat> > &ParticularUI<enorm<ldmat> >::factory ( 
    15     ParticularUI<enorm<ldmat> > ( "enorm<ldmat>" ) ); 
    16  
    17 template<> 
    18 const ParticularUI<enorm<fsqmat> > &ParticularUI<enorm<fsqmat> >::factory ( 
    19     ParticularUI<enorm<fsqmat> > ( "enorm<fsqmat>" ) ); 
    20  
    21 template<> 
    22 const ParticularUI<enorm<chmat> > &ParticularUI<enorm<chmat> >::factory ( 
    23     ParticularUI<enorm<chmat> > ( "enorm<chmat>" ) ); 
    247 
    258TEST ( test_egamma ) { 
  • library/tests/loggers_test.cpp

    r477 r493  
    1 #define BDMLIB // not an ideal way to prevent double registration of UI factories... 
    21#include "base/loggers.h" 
    32#include "test_util.h" 
  • library/tests/mpdf_harness.cpp

    r484 r493  
    88 
    99namespace bdm { 
    10  
    11 template<> 
    12 const ParticularUI<mpdf_harness> &ParticularUI<mpdf_harness>::factory ( 
    13     ParticularUI<mpdf_harness> ( "mpdf_harness" ) ); 
    1410 
    1511void mpdf_harness::test_config ( const char *config_file_name ) { 
  • library/tests/mpdf_harness.h

    r484 r493  
    1313#ifndef MPDF_HARNESS_H 
    1414#define MPDF_HARNESS_H 
    15  
    16 #define BDMLIB // not an ideal way to prevent double registration of UI factories... 
    1715 
    1816#include "bdmroot.h" 
     
    5452        void check_covariance(); 
    5553}; 
     54UIREGISTER(mpdf_harness); 
    5655 
    5756} 
  • library/tests/mpdf_test.cpp

    r492 r493  
    1 #define BDMLIB // not an ideal way to prevent double registration of UI factories... 
    21#include "base/bdmbase.h" 
    32#include "base/user_info.h" 
     
    98 
    109using namespace bdm; 
    11  
    12 template<> 
    13 const ParticularUI<mgamma> &ParticularUI<mgamma>::factory ( 
    14     ParticularUI<mgamma> ( "mgamma" ) ); 
    15  
    16 template<> 
    17 const ParticularUI<mlnorm<ldmat> > &ParticularUI<mlnorm<ldmat> >::factory ( 
    18     ParticularUI<mlnorm<ldmat> > ( "mlnorm<ldmat>" ) ); 
    19  
    20 template<> 
    21 const ParticularUI<mlnorm<chmat> > &ParticularUI<mlnorm<chmat> >::factory ( 
    22     ParticularUI<mlnorm<chmat> > ( "mlnorm<chmat>" ) ); 
    2310 
    2411TEST ( test_mepdf ) { 
  • library/tests/test_util.cpp

    r486 r493  
    1 #define BDMLIB // not an ideal way to prevent double registration of UI factories... 
    21#include "test_util.h" 
    32#include "stat/exp_family.h"