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
14namespace 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
static AtmosModel * Create(Pvl &pvl, PhotoModel &pmodel)
Create an AtmosModel object using a PVL specification.
Isotropic atmos scattering model.
Definition AtmosModel.h:60
File name manipulation and expansion.
Definition FileName.h:100
bool fileExists() const
Returns true if the file exists; false otherwise.
Definition FileName.cpp:449
Isis exception class.
Definition IException.h:91
@ User
A type of error that could only have occurred due to a mistake on the user's part (e....
Definition IException.h:126
Loads plugins from a shared library.
Definition Plugin.h:55
Contains multiple PvlContainers.
Definition PvlGroup.h:41
Container for cube-like labels.
Definition Pvl.h:119
@ Traverse
Search child objects.
Definition PvlObject.h:158
This is free and unencumbered software released into the public domain.
Definition Apollo.h:16