Isis 3 Programmer Reference
NormModelFactory.cpp
1
6/* SPDX-License-Identifier: CC0-1.0 */
7
8#include "NormModelFactory.h"
9#include "NormModel.h"
10#include "Plugin.h"
11#include "IException.h"
12#include "FileName.h"
13
14namespace Isis {
37 // Get the algorithm name to create
38 PvlGroup &algo = pvl.findObject("NormalizationModel")
39 .findGroup("Algorithm", Pvl::Traverse);
40 QString algorithm = "";
41 if (algo.hasKeyword("NormName")) {
42 algorithm = QString(algo["NormName"]);
43 }
44 else if (algo.hasKeyword("Name")) {
45 algorithm = QString(algo["Name"]);
46 }
47 else {
48 QString msg = "Keyword [Name] or keyword [NormName] must ";
49 msg += "exist in [Group = Algorithm]";
50 throw IException(IException::User, msg, _FILEINFO_);
51 }
52
53 // Open the factory plugin file
54 Plugin *p = new Plugin;
55 FileName f("NormModel.plugin");
56 if(f.fileExists()) {
57 p->read("NormModel.plugin");
58 }
59 else {
60 p->read("$ISISROOT/lib/NormModel.plugin");
61 }
62
63 // Get the algorithm specific plugin and return it
64 NormModel * (*plugin)(Pvl & pvl, PhotoModel & pmodel);
65 plugin = (NormModel * ( *)(Pvl & pvl, PhotoModel & pmodel))
66 p->GetPlugin(algorithm);
67 return (*plugin)(pvl, pmodel);
68 }
69
92 AtmosModel &amodel) {
93 // Get the algorithm name to create
94 PvlGroup &algo = pvl.findObject("NormalizationModel")
95 .findGroup("Algorithm", Pvl::Traverse);
96 QString algorithm = "";
97 if (algo.hasKeyword("NormName")) {
98 algorithm = QString(algo["NormName"]);
99 }
100 else if (algo.hasKeyword("Name")) {
101 algorithm = QString(algo["Name"]);
102 }
103 else {
104 IString msg = "Keyword [Name] or keyword [NormName] must ";
105 msg += "exist in [Group = Algorithm]";
106 throw IException(IException::User, msg, _FILEINFO_);
107 }
108
109 // Open the factory plugin file
110 Plugin *p = new Plugin;
111 FileName f("NormModel.plugin");
112 if(f.fileExists()) {
113 p->read("NormModel.plugin");
114 }
115 else {
116 p->read("$ISISROOT/lib/NormModel.plugin");
117 }
118
119 // Get the algorithm specific plugin and return it
120 NormModel * (*plugin)(Pvl & pvl, PhotoModel & pmodel,
121 AtmosModel & amodel);
122 plugin = (NormModel * ( *)(Pvl & pvl, PhotoModel & pmodel,
123 AtmosModel & amodel))
124 p->GetPlugin(algorithm);
125 return (*plugin)(pvl, pmodel, amodel);
126 }
127} // end namespace isis
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
Adds specific functionality to C++ strings.
Definition IString.h:165
static NormModel * Create(Pvl &pvl, PhotoModel &pmodel)
Create a NormModel object using a PVL specification.
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