aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorastrojhgu <astrojhgu@ed2142bd-67ad-457f-ba7c-d818d4011675>2011-01-20 17:32:15 +0000
committerastrojhgu <astrojhgu@ed2142bd-67ad-457f-ba7c-d818d4011675>2011-01-20 17:32:15 +0000
commit50e769e8f1a5234c3ca3969088e407d3212e6ce3 (patch)
tree9ed3e60b3b54bf03c5d8abc1d70a202a1c546db8
parent753815615b9a0f39cc19961c5388902ee3a63654 (diff)
downloadopt-utilities-50e769e8f1a5234c3ca3969088e407d3212e6ce3.tar.bz2
git-svn-id: file:///home/svn/opt_utilities@165 ed2142bd-67ad-457f-ba7c-d818d4011675
-rw-r--r--models/models.cc78
-rw-r--r--models/models.hpp12
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 <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;
-
-
}
diff --git a/models/models.hpp b/models/models.hpp
index b3bf762..76a8ecf 100644
--- a/models/models.hpp
+++ b/models/models.hpp
@@ -13,30 +13,20 @@
#include <string>
#include <list>
#include "vecn.hpp"
-#include "strmodel1d.hpp"
namespace opt_utilities
{
extern std::map<std::string,model<double,double,std::vector<double>,std::string>* > model_map;
- extern std::map<std::string,model<double,vecn<double,2>,std::vector<double>,std::string >* > model2d_map;
- extern strmodel1d strm1d;
extern std::list<std::string> get_model_name_list();
extern int get_n_1dmodels();
// extern void init_model_map();
// extern void release_model_map();
- extern std::list<std::string> get_model2d_name_list();
- // extern void init_model2d_map();
- // extern void release_model2d_map();
- extern int get_n_2dmodels();
-
extern model<double,double,std::vector<double>,std::string >& get_1dmodel_by_name(const char*);
- extern model<double,vecn<double,2>,std::vector<double>,std::string >& get_2dmodel_by_name(const char*);
-
- extern strmodel1d& get_strm1d();
+ extern const char* get_model_name(int n);
}