ModelRegister.cc
Go to the documentation of this file.
1 
9 #include <atm/ModelRegister.h>
10 #include <atm/VRayleighModel.h>
11 #include <atm/VProfileModel.h>
12 #include <atm/VMieModel.h>
13 #include <atm/VFluorescenceModel.h>
14 #include <atm/VCherenkovModel.h>
15 #include <atm/VCloudModel.h>
16 
17 #include <utl/AugerException.h>
18 #include <utl/ErrorLogger.h>
19 #include <sstream>
20 
21 using namespace atm;
22 using namespace std;
23 
24 
25 template<typename ModelType>
26 void
28  ModelType* const model)
29 {
30  fMap[modelName] = model;
31 }
32 
33 
34 template<typename ModelType>
35 ModelType&
36 ModelRegister<ModelType>::Get(const string& modelName)
37 {
38  const typename InternalCollection::iterator it =
39  fMap.find(modelName);
40 
41  if (it == fMap.end()) {
42  ostringstream err;
43  err << "Could not retrieve model '" << modelName << '\'';
44  ERROR(err);
46  }
47 
48  return *it->second;
49 }
50 
51 
52 template<typename ModelType>
53 const ModelType&
54 ModelRegister<ModelType>::Get(const string& modelName)
55  const
56 {
57  const typename InternalCollection::const_iterator it =
58  fMap.find(modelName);
59 
60  if (it == fMap.end()) {
61  ostringstream err;
62  err << "Could not retrieve model '" << modelName << '\'';
63  ERROR(err);
65  }
66 
67  return *it->second;
68 }
69 
70 
71 template<typename ModelType>
73 {
74  for (typename InternalCollection::iterator it = fMap.begin();
75  it != fMap.end(); ++it)
76  delete it->second;
77 }
78 
79 namespace atm {
80  template class ModelRegister<atm::VMieModel>;
81  template class ModelRegister<atm::VProfileModel>;
85  template class ModelRegister<atm::VCloudModel>;
86 };
87 
88 // Configure (x)emacs for this file ...
89 // Local Variables:
90 // mode: c++
91 // compile-command: "make -C .. -k"
92 // End:
void RegisterModel(const std::string &modelName, ModelType *const model)
Base class for exceptions trying to access non-existing components.
Registry of atmosphere models.
Definition: ModelRegister.h:28
#define ERROR(message)
Macro for logging error messages.
Definition: ErrorLogger.h:165
ModelType & Get(const std::string &name)

, generated on Tue Sep 26 2023.