aboutsummaryrefslogtreecommitdiffstats
path: root/models/models.cc
diff options
context:
space:
mode:
Diffstat (limited to 'models/models.cc')
-rw-r--r--models/models.cc78
1 files changed, 9 insertions, 69 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 <iostream>
using namespace std;
namespace opt_utilities
{
- strmodel1d strm1d;
std::map<std::string,model<double,double,std::vector<double>,std::string>* > model_map;
- std::map<std::string,model<double,vecn<double,2>,std::vector<double>,std::string>* > model2d_map;
+
std::list<std::string> get_model_name_list()
{
std::list<std::string> result;
@@ -36,15 +30,17 @@ namespace opt_utilities
return result;
}
- std::list<std::string> get_model2d_name_list()
+ const char* get_model_name(int n)
{
- std::list<std::string> result;
- for(map<std::string,model<double,vecn<double,2>,std::vector<double>,std::string>* > ::iterator i=model2d_map.begin();
- i!=model2d_map.end();++i)
+ int cnt=0;
+ for(std::map<std::string,model<double,double,std::vector<double>,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<double,double,std::vector<double>,std::string>& get_1dmodel_by_name(const char* name)
@@ -58,32 +54,12 @@ model<double,double,std::vector<double>,std::string>& get_1dmodel_by_name(const
return *(iter->second);
}
- strmodel1d& get_strm1d()
- {
- return strm1d;
- }
-
-model<double,vecn<double,2>,std::vector<double>,std::string>& get_2dmodel_by_name(const char* name)
- {
- std::map<std::string,model<double,vecn<double,2>,std::vector<double>,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<double,vecn<double,2>,std::vector<double>,std::string>& get_2dmodel_by_nam
}model_map_keeper;
- class model2d_map_keeper_class
- {
- private:
- void init_model_map()
- {
- model2d_map["beta2d"]=new beta2d<double>;
- model2d_map["beta2d2"]=new beta2d2<double>;
- model2d_map["dbeta2d"]=new dbeta2d<double>;
- model2d_map["dbeta2d2"]=new dbeta2d2<double>;
- model2d_map["dbeta2d3"]=new dbeta2d3<double>;
- }
-
- void release_model_map()
- {
- for(std::map<std::string,model<double,vecn<double,2>,std::vector<double>,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"<<std::endl;
- }
-
- ~model2d_map_keeper_class()
- {
- release_model_map();
- std::cerr<<"2d models Released"<<std::endl;
- }
-
- }model2d_map_keeper;
-
-
}