Isis 3 Programmer Reference
NormModelFactory.cpp
Go to the documentation of this file.
1 
24 #include "NormModelFactory.h"
25 #include "NormModel.h"
26 #include "Plugin.h"
27 #include "IException.h"
28 #include "FileName.h"
29 
30 namespace Isis {
53  // Get the algorithm name to create
54  PvlGroup &algo = pvl.findObject("NormalizationModel")
55  .findGroup("Algorithm", Pvl::Traverse);
56  QString algorithm = "";
57  if (algo.hasKeyword("NormName")) {
58  algorithm = QString(algo["NormName"]);
59  }
60  else if (algo.hasKeyword("Name")) {
61  algorithm = QString(algo["Name"]);
62  }
63  else {
64  QString msg = "Keyword [Name] or keyword [NormName] must ";
65  msg += "exist in [Group = Algorithm]";
67  }
68 
69  // Open the factory plugin file
70  Plugin *p = new Plugin;
71  FileName f("NormModel.plugin");
72  if(f.fileExists()) {
73  p->read("NormModel.plugin");
74  }
75  else {
76  p->read("$ISISROOT/lib/NormModel.plugin");
77  }
78 
79  // Get the algorithm specific plugin and return it
80  NormModel * (*plugin)(Pvl & pvl, PhotoModel & pmodel);
81  plugin = (NormModel * ( *)(Pvl & pvl, PhotoModel & pmodel))
82  p->GetPlugin(algorithm);
83  return (*plugin)(pvl, pmodel);
84  }
85 
108  AtmosModel &amodel) {
109  // Get the algorithm name to create
110  PvlGroup &algo = pvl.findObject("NormalizationModel")
111  .findGroup("Algorithm", Pvl::Traverse);
112  QString algorithm = "";
113  if (algo.hasKeyword("NormName")) {
114  algorithm = QString(algo["NormName"]);
115  }
116  else if (algo.hasKeyword("Name")) {
117  algorithm = QString(algo["Name"]);
118  }
119  else {
120  IString msg = "Keyword [Name] or keyword [NormName] must ";
121  msg += "exist in [Group = Algorithm]";
123  }
124 
125  // Open the factory plugin file
126  Plugin *p = new Plugin;
127  FileName f("NormModel.plugin");
128  if(f.fileExists()) {
129  p->read("NormModel.plugin");
130  }
131  else {
132  p->read("$ISISROOT/lib/NormModel.plugin");
133  }
134 
135  // Get the algorithm specific plugin and return it
136  NormModel * (*plugin)(Pvl & pvl, PhotoModel & pmodel,
137  AtmosModel & amodel);
138  plugin = (NormModel * ( *)(Pvl & pvl, PhotoModel & pmodel,
139  AtmosModel & amodel))
140  p->GetPlugin(algorithm);
141  return (*plugin)(pvl, pmodel, amodel);
142  }
143 } // end namespace isis
bool hasKeyword(const QString &name) const
Check to see if a keyword exists.
File name manipulation and expansion.
Definition: FileName.h:116
PvlObjectIterator findObject(const QString &name, PvlObjectIterator beg, PvlObjectIterator end)
Find the index of object with a specified name, between two indexes.
Definition: PvlObject.h:286
Search child objects.
Definition: PvlObject.h:170
Loads plugins from a shared library.
Definition: Plugin.h:71
Isotropic atmos scattering model.
Definition: AtmosModel.h:76
Contains multiple PvlContainers.
Definition: PvlGroup.h:57
#define _FILEINFO_
Macro for the filename and line number.
Definition: IException.h:40
A type of error that could only have occurred due to a mistake on the user's part (e...
Definition: IException.h:142
Container for cube-like labels.
Definition: Pvl.h:135
static NormModel * Create(Pvl &pvl, PhotoModel &pmodel)
Create a NormModel object using a PVL specification.
Isis exception class.
Definition: IException.h:107
Adds specific functionality to C++ strings.
Definition: IString.h:181
Namespace for ISIS/Bullet specific routines.
Definition: Apollo.h:31
QFunctionPointer GetPlugin(const QString &group)
This method returns a void pointer to a C function (i.e., the plugin) It does this by looking in itse...
Definition: Plugin.cpp:55
void read(const QString &file)
Loads PVL information from a stream.
Definition: Pvl.cpp:76
bool fileExists() const
Returns true if the file exists; false otherwise.
Definition: FileName.cpp:465