Isis 3 Programmer Reference
PhotoModelFactory.cpp
Go to the documentation of this file.
1 
24 #include "PhotoModelFactory.h"
25 #include "PhotoModel.h"
26 #include "Plugin.h"
27 #include "IException.h"
28 #include "FileName.h"
29 
30 namespace Isis {
52  // Get the algorithm name to create
53  PvlGroup &algo = pvl.findObject("PhotometricModel")
54  .findGroup("Algorithm", Pvl::Traverse);
55 
56  QString algorithm = "";
57  if (algo.hasKeyword("PhtName")) {
58  algorithm = algo["PhtName"][0];
59  }
60  else if (algo.hasKeyword("Name")) {
61  algorithm = algo["Name"][0];
62  }
63  else {
64  QString msg = "Keyword [Name] or keyword [PhtName] must ";
65  msg += "exist in [Group = Algorithm]";
67  }
68 
69  // Open the factory plugin file
70  Plugin *p = new Plugin;
71  FileName f("PhotoModel.plugin");
72  if(f.fileExists()) {
73  p->read("PhotoModel.plugin");
74  }
75  else {
76  p->read("$ISISROOT/lib/PhotoModel.plugin");
77  }
78 
79  // Get the algorithm specific plugin and return it
80  PhotoModel * (*plugin)(Pvl & pvl);
81  plugin = (PhotoModel * ( *)(Pvl & pvl)) p->GetPlugin(algorithm);
82  return (*plugin)(pvl);
83  }
84 } // 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
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
static PhotoModel * Create(Pvl &pvl)
Create a PhotoModel object using a PVL specification.
Container for cube-like labels.
Definition: Pvl.h:135
Isis exception class.
Definition: IException.h:107
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