#include "models.hpp" #include #include "gauss1d.hpp" #include "bl1d.hpp" #include "nfw1d.hpp" #include "bpl1d.hpp" #include "beta1d.hpp" #include "nbeta1d.hpp" #include "dbeta1d.hpp" #include "lin1d.hpp" #include "pl1d.hpp" #include "poly1d.hpp" #include "bremss.hpp" #include "beta2d2.hpp" #include "beta2d.hpp" #include "dbeta2d2.hpp" #include "dbeta2d3.hpp" #include "dbeta2d.hpp" #include "dl_model.hpp" #include using namespace std; namespace opt_utilities { strmodel1d strm1d; std::map,std::string>* > model_map; std::map,std::vector,std::string>* > model2d_map; std::list get_model_name_list() { std::list result; for(std::map,std::string>* >::iterator i=model_map.begin(); i!=model_map.end();++i) { result.push_back(i->first); } return result; } std::list get_model2d_name_list() { std::list result; for(map,std::vector,std::string>* > ::iterator i=model2d_map.begin(); i!=model2d_map.end();++i) { result.push_back(i->first); } return result; } model,std::string>& get_1dmodel_by_name(const char* name) { std::map,std::string >* >::iterator iter; iter=model_map.find(name); if(iter==model_map.end()||iter->second==0) { throw opt_exception("model does not exist"); } return *(iter->second); } strmodel1d& get_strm1d() { return strm1d; } model,std::vector,std::string>& get_2dmodel_by_name(const char* name) { std::map,std::vector,std::string>* >::iterator iter; iter=model2d_map.find(name); if(iter==model2d_map.end()||iter->second==0) { throw opt_exception("model does not exist"); } return *(iter->second); } int get_n_1dmodels() { return model_map.size(); } int get_n_2dmodels() { return model2d_map.size(); } class model_map_keeper_class { private: void init_model_map() { //#define DECL_POLY(n) model_map["poly1d##n"]=new poly1d; model_map["lin1d"]=new lin1d; model_map["pl1d"]=new pl1d; model_map["bl1d"]=new bl1d; model_map["bpl1d"]=new bpl1d; model_map["beta1d"]=new beta1d; model_map["bremss"]=new bremss; model_map["nbeta1d"]=new nbeta1d; model_map["2beta1d"]=new dbeta1d; model_map["nfw"]=new nfw1d; model_map["gauss1d"]=new gauss1d; model_map["poly1d2"]=new poly1d; model_map["poly1d3"]=new poly1d; model_map["poly1d4"]=new poly1d; model_map["poly1d5"]=new poly1d; #ifdef __linux__ model_map["dlmodel"]=new dl_model; #endif //DECL_POLY(7) } void release_model_map() { for(std::map,std::string>* >::iterator i=model_map.begin(); i!=model_map.end();++i) { delete i->second; } } public: model_map_keeper_class() { init_model_map(); std::cerr<<"1d models Initialized"<; model2d_map["beta2d2"]=new beta2d2; model2d_map["dbeta2d"]=new dbeta2d; model2d_map["dbeta2d2"]=new dbeta2d2; model2d_map["dbeta2d3"]=new dbeta2d3; } void release_model_map() { for(std::map,std::vector,std::string>* >::iterator i=model2d_map.begin(); i!=model2d_map.end();++i) { delete i->second; } } public: model2d_map_keeper_class() { init_model_map(); std::cerr<<"2d models Initialized"<