From 50e769e8f1a5234c3ca3969088e407d3212e6ce3 Mon Sep 17 00:00:00 2001 From: astrojhgu Date: Thu, 20 Jan 2011 17:32:15 +0000 Subject: git-svn-id: file:///home/svn/opt_utilities@165 ed2142bd-67ad-457f-ba7c-d818d4011675 --- models/models.cc | 78 +++++++------------------------------------------------ models/models.hpp | 12 +-------- 2 files changed, 10 insertions(+), 80 deletions(-) diff --git a/models/models.cc b/models/models.cc index 6cb6536..551c33c 100644 --- a/models/models.cc +++ b/models/models.cc @@ -11,20 +11,14 @@ #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 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; @@ -36,15 +30,17 @@ namespace opt_utilities return result; } - std::list get_model2d_name_list() + const char* get_model_name(int n) { - std::list result; - for(map,std::vector,std::string>* > ::iterator i=model2d_map.begin(); - i!=model2d_map.end();++i) + int cnt=0; + for(std::map,std::string>* >::iterator i=model_map.begin(); + i!=model_map.end();++i) { - result.push_back(i->first); + if(cnt++==n) + { + return i->first.c_str(); + } } - return result; } model,std::string>& get_1dmodel_by_name(const char* name) @@ -58,32 +54,12 @@ model,std::string>& get_1dmodel_by_name(const 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: @@ -133,41 +109,5 @@ model,std::vector,std::string>& get_2dmodel_by_nam }model_map_keeper; - class model2d_map_keeper_class - { - private: - void init_model_map() - { - model2d_map["beta2d"]=new beta2d; - 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"< #include #include "vecn.hpp" -#include "strmodel1d.hpp" namespace opt_utilities { extern std::map,std::string>* > model_map; - extern std::map,std::vector,std::string >* > model2d_map; - extern strmodel1d strm1d; extern std::list get_model_name_list(); extern int get_n_1dmodels(); // extern void init_model_map(); // extern void release_model_map(); - extern std::list get_model2d_name_list(); - // extern void init_model2d_map(); - // extern void release_model2d_map(); - extern int get_n_2dmodels(); - extern model,std::string >& get_1dmodel_by_name(const char*); - extern model,std::vector,std::string >& get_2dmodel_by_name(const char*); - - extern strmodel1d& get_strm1d(); + extern const char* get_model_name(int n); } -- cgit v1.2.2