Isis 3 Programmer Reference
AtmosModelFactory.cpp
1 
6 /* SPDX-License-Identifier: CC0-1.0 */
7 
8 #include "AtmosModelFactory.h"
9 #include "AtmosModel.h"
10 #include "Plugin.h"
11 #include "IException.h"
12 #include "FileName.h"
13 
14 namespace Isis {
45 
46  // Get the algorithm name to create
47  PvlGroup &algo = pvl.findObject("AtmosphericModel")
48  .findGroup("Algorithm", Pvl::Traverse);
49 
50  QString algorithm = "";
51  if(algo.hasKeyword("AtmName")) {
52  algorithm = QString(algo["AtmName"]);
53  }
54  else if(algo.hasKeyword("Name")) {
55  algorithm = QString(algo["Name"]);
56  }
57  else {
58  QString msg = "Keyword [Name] or keyword [AtmName] must ";
59  msg += "exist in [Group = Algorithm]";
60  throw IException(IException::User, msg, _FILEINFO_);
61  }
62 
63  // Open the factory plugin file
64  Plugin *p = new Plugin;
65  FileName f("AtmosModel.plugin");
66  if(f.fileExists()) {
67  p->read("AtmosModel.plugin");
68  }
69  else {
70  p->read("$ISISROOT/lib/AtmosModel.plugin");
71  }
72 
73  // Get the algorithm specific plugin and return it
74  AtmosModel * (*plugin)(Pvl & pvl, PhotoModel & pmodel);
75  plugin = (AtmosModel * ( *)(Pvl & pvl, PhotoModel & pmodel))
76  p->GetPlugin(algorithm);
77  return (*plugin)(pvl, pmodel);
78  }
79 } // end namespace isis
Isis::PhotoModel
Definition: PhotoModel.h:41
Isis::AtmosModelFactory::Create
static AtmosModel * Create(Pvl &pvl, PhotoModel &pmodel)
Create an AtmosModel object using a PVL specification.
Definition: AtmosModelFactory.cpp:44
Isis::FileName
File name manipulation and expansion.
Definition: FileName.h:100
Isis::FileName::fileExists
bool fileExists() const
Returns true if the file exists; false otherwise.
Definition: FileName.cpp:449
Isis::AtmosModel
Isotropic atmos scattering model.
Definition: AtmosModel.h:60
Isis::PvlContainer::hasKeyword
bool hasKeyword(const QString &name) const
Check to see if a keyword exists.
Definition: PvlContainer.cpp:159
Isis::Pvl
Container for cube-like labels.
Definition: Pvl.h:119
Isis::PvlObject::Traverse
@ Traverse
Search child objects.
Definition: PvlObject.h:158
Isis::PvlGroup
Contains multiple PvlContainers.
Definition: PvlGroup.h:41
Isis::Pvl::read
void read(const QString &file)
Loads PVL information from a stream.
Definition: Pvl.cpp:90
Isis::PvlObject::findObject
PvlObjectIterator findObject(const QString &name, PvlObjectIterator beg, PvlObjectIterator end)
Find the index of object with a specified name, between two indexes.
Definition: PvlObject.h:274
Isis::Plugin::GetPlugin
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:39
Isis::IException
Isis exception class.
Definition: IException.h:91
Isis
This is free and unencumbered software released into the public domain.
Definition: Apollo.h:16
Isis::IException::User
@ User
A type of error that could only have occurred due to a mistake on the user's part (e....
Definition: IException.h:126
Isis::Plugin
Loads plugins from a shared library.
Definition: Plugin.h:55