Changeset 529 for library/bdm
- Timestamp:
- 08/14/09 09:03:02 (15 years ago)
- Location:
- library/bdm
- Files:
-
- 12 modified
Legend:
- Unmodified
- Added
- Removed
-
library/bdm/base/bdmbase.h
r527 r529 226 226 }; 227 227 UIREGISTER (RV); 228 SHAREDPTR (RV); 228 229 229 230 //! Concat two random variables … … 386 387 387 388 }; 388 389 SHAREDPTR(epdf); 389 390 390 391 //! Conditional probability density, e.g. modeling some dependencies. … … 487 488 //!@} 488 489 }; 490 SHAREDPTR(mpdf); 489 491 490 492 template <class EPDF> … … 740 742 }; 741 743 UIREGISTER (mepdf); 744 SHAREDPTR (mepdf); 742 745 743 746 //! \brief Combines RVs from a list of mpdfs to a single one. … … 990 993 }; 991 994 995 typedef Array<shared_ptr<epdf> > epdf_array; 996 997 typedef Array<shared_ptr<mpdf> > mpdf_array; 998 992 999 template<class EPDF> 993 1000 vec mpdf_internal<EPDF>::samplecond (const vec &cond) -
library/bdm/base/datasources.h
r527 r529 107 107 108 108 UIREGISTER ( ITppFileDS ); 109 SHAREDPTR ( ITppFileDS ); 109 110 110 111 /*! … … 263 264 264 265 UIREGISTER ( ArxDS ); 266 SHAREDPTR ( ArxDS ); 265 267 266 268 class stateDS : public DS { … … 346 348 347 349 UIREGISTER ( stateDS ); 350 SHAREDPTR ( stateDS ); 348 351 349 352 }; //namespace -
library/bdm/base/loggers.h
r477 r529 92 92 93 93 UIREGISTER ( memlog ); 94 SHAREDPTR ( memlog ); 94 95 95 96 /*! … … 139 140 140 141 UIREGISTER ( dirfilelog ); 142 SHAREDPTR ( dirfilelog ); 141 143 142 144 }; -
library/bdm/base/user_info.h
r527 r529 550 550 ParticularUI<T> ( const string &class_name ) : UI ( class_name, &typeid ( T ) ) {}; 551 551 552 //! A method returning a brand new instance of class T, this method is the reason why there have to be a parameterless construc otor in class T552 //! A method returning a brand new instance of class T, this method is the reason why there have to be a parameterless constructor in class T 553 553 root* new_instance() const { 554 554 return new T(); … … 565 565 \brief Macro for registration of class into map of user-infos, registered class is scriptable using UI static methods 566 566 567 Argument \a class_name has to be a descendant of root class and also , it has to have parameterless constructor prepared.567 Argument \a class_name has to be a descendant of root class and also to have a default constructor. 568 568 This macro should be used in header file, immediately after a class declaration. 569 569 -
library/bdm/estim/arx.h
r477 r529 164 164 165 165 UIREGISTER ( ARX ); 166 SHAREDPTR ( ARX ); 166 167 167 168 } -
library/bdm/estim/kalman.h
r527 r529 280 280 281 281 UIREGISTER ( EKFCh ); 282 SHAREDPTR ( EKFCh ); 282 283 283 284 … … 466 467 467 468 UIREGISTER ( MultiModel ); 469 SHAREDPTR ( MultiModel ); 468 470 469 471 -
library/bdm/mex/mex_datasource.h
r477 r529 40 40 it_assert_debug ( time < Data.cols(), "MemDS delays are too high." ); 41 41 42 RV*r = UI::build<RV> ( set, "rv", UI::compulsory );42 shared_ptr<RV> r = UI::build<RV> ( set, "rv", UI::compulsory ); 43 43 RV ru = RV(); 44 44 set_rvs ( *r, ru ); … … 50 50 51 51 UIREGISTER ( MexDS ); 52 SHAREDPTR ( MexDS ); 52 53 53 54 } -
library/bdm/mex/mex_logger.h
r477 r529 71 71 }; 72 72 UIREGISTER ( mexlog ); 73 SHAREDPTR ( mexlog ); 73 74 } -
library/bdm/shared_ptr.h
r477 r529 1 1 /*! 2 2 \file 3 \brief BDM's own smart pointer .3 \brief BDM's own smart pointers. 4 4 \author Vaclav Barta. 5 5 … … 22 22 namespace bdm { 23 23 24 //! A naive implementation of roughly a subset of the std::tr1:shared_ptr spec (really just roughly - it ignores memory exceptions, for example; also note I didn't read the spec). 25 // The standard template would naturally be preferable, _if_ it was 26 // included in the standard libraries of all supported compilers - but 27 // that's exactly what remains to be seen... 24 /*! \brief A naive implementation of roughly a subset of the std::tr1:shared_ptr spec 25 26 Really just roughly - it ignores memory 27 exceptions, for example; also note I didn't read the spec. 28 29 The standard template would naturally be preferable, _if_ it was 30 included in the standard libraries of all supported compilers - but 31 as of 2009, that's still a problem... 32 */ 28 33 template <typename T> 29 34 class shared_ptr { … … 41 46 } 42 47 43 //! Constructs a shared_ptr that owns the pointer p (unless p is 44 //! null, in which case this constructor creates an empty 45 //! shared_ptr). 48 /*! 49 Constructs a shared_ptr that owns the pointer p (unless p 50 is NULL, in which case this constructor creates an empty 51 shared_ptr). When p isn't null, it must have been alllocated 52 by new! 53 */ 46 54 shared_ptr ( T *p ) : 47 55 payload ( p ), … … 70 78 } 71 79 72 shared_ptr &operator= ( const shared_ptr&other ) {80 shared_ptr<T> &operator= ( const shared_ptr<T> &other ) { 73 81 other.add_ref(); 74 82 del_ref(); … … 178 186 } 179 187 188 /*! \brief A wrapper of shared_ptr which is never empty. 189 190 T must have a default constructor. 191 192 Note that shared_ptr's destructor isn't virtual - don't call delete 193 on pointers to instances of this class. 194 */ 195 template <typename T> 196 class object_ptr : public shared_ptr<T> 197 { 198 public: 199 /*! 200 \brief Default constructor 201 202 Calls T's default constructor. 203 */ 204 object_ptr() : shared_ptr<T> ( new T() ) { } 205 206 /*! 207 \brief Upcast from shared_ptr<T> to object_ptr<T> 208 209 \param b The shared pointer, which must not be empty. 210 */ 211 object_ptr ( const shared_ptr<T> &b ) : shared_ptr<T> ( b ) { 212 it_assert_debug ( this->get(), "object_ptr cannot be empty" ); 213 } 214 215 /*! 216 Constructs an object_ptr that owns the pointer p. p must 217 have been alllocated by new! 218 */ 219 object_ptr ( T *p ) : shared_ptr<T> ( p ) { 220 it_assert_debug ( p, "object_ptr cannot be empty" ); 221 } 222 223 object_ptr<T> &operator= ( const object_ptr<T> &other ) { 224 shared_ptr<T>::operator= ( other ); 225 return *this; 226 } 227 }; 228 229 #define SHAREDPTR(class_name) typedef bdm::object_ptr< class_name > class_name##_ptr 230 231 #define SHAREDPTR2(template_class_name, template_parameter_name) typedef bdm::object_ptr< template_class_name < template_parameter_name > > template_class_name##_##template_parameter_name##_ptr 232 180 233 } 181 234 -
library/bdm/stat/emix.h
r527 r529 186 186 } 187 187 }; 188 188 SHAREDPTR( emix ); 189 189 190 190 /*! … … 362 362 }; 363 363 UIREGISTER ( mprod ); 364 SHAREDPTR ( mprod ); 364 365 365 366 //! Product of independent epdfs. For dependent pdfs, use mprod. -
library/bdm/stat/exp_family.h
r527 r529 165 165 }; 166 166 UIREGISTER (enorm<chmat>); 167 SHAREDPTR2 ( enorm, chmat ); 167 168 UIREGISTER (enorm<ldmat>); 169 SHAREDPTR2 ( enorm, ldmat ); 168 170 UIREGISTER (enorm<fsqmat>); 171 SHAREDPTR2 ( enorm, fsqmat ); 169 172 170 173 … … 241 244 //!@} 242 245 }; 243 UIREGISTER (egiw); 246 UIREGISTER ( egiw ); 247 SHAREDPTR ( egiw ); 244 248 245 249 /*! \brief Dirichlet posterior density … … 399 403 }; 400 404 UIREGISTER (egamma); 405 SHAREDPTR ( egamma ); 406 401 407 /*! 402 408 \brief Inverse-Gamma posterior density … … 566 572 }; 567 573 UIREGISTER (mlnorm<ldmat>); 574 SHAREDPTR2 ( mlnorm, ldmat ); 568 575 UIREGISTER (mlnorm<fsqmat>); 576 SHAREDPTR2 ( mlnorm, fsqmat ); 569 577 UIREGISTER (mlnorm<chmat>); 578 SHAREDPTR2 ( mlnorm, chmat ); 570 579 571 580 //! Mpdf with general function for mean value … … 627 636 628 637 UIREGISTER (mgnorm<chmat>); 638 SHAREDPTR2 ( mgnorm, chmat ); 629 639 630 640 … … 716 726 }; 717 727 UIREGISTER (mgamma); 728 SHAREDPTR (mgamma); 718 729 719 730 /*! … … 860 871 861 872 UIREGISTER (migamma_ref); 873 SHAREDPTR (migamma_ref); 862 874 863 875 /*! Log-Normal probability density … … 941 953 942 954 UIREGISTER (mlognorm); 955 SHAREDPTR (mlognorm); 943 956 944 957 /*! inverse Wishart density defined on Choleski decomposition -
library/bdm/stat/merger.h
r507 r529 316 316 }; 317 317 UIREGISTER ( merger_base ); 318 SHAREDPTR ( merger_base ); 318 319 319 320 class merger_mix : public merger_base { … … 398 399 }; 399 400 UIREGISTER ( merger_mix ); 401 SHAREDPTR ( merger_mix ); 400 402 401 403 }