Isis 3 Programmer Reference
PhotoModelFactory.cpp
1
6/* SPDX-License-Identifier: CC0-1.0 */
7
8#include "PhotoModelFactory.h"
9#include "PhotoModel.h"
10#include "Plugin.h"
11#include "IException.h"
12#include "FileName.h"
13
14namespace Isis {
36 // Get the algorithm name to create
37 PvlGroup &algo = pvl.findObject("PhotometricModel")
38 .findGroup("Algorithm", Pvl::Traverse);
39
40 QString algorithm = "";
41 if (algo.hasKeyword("PhtName")) {
42 algorithm = algo["PhtName"][0];
43 }
44 else if (algo.hasKeyword("Name")) {
45 algorithm = algo["Name"][0];
46 }
47 else {
48 QString msg = "Keyword [Name] or keyword [PhtName] 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("PhotoModel.plugin");
56 if(f.fileExists()) {
57 p->read("PhotoModel.plugin");
58 }
59 else {
60 p->read("$ISISROOT/lib/PhotoModel.plugin");
61 }
62
63 // Get the algorithm specific plugin and return it
64 PhotoModel * (*plugin)(Pvl & pvl);
65 plugin = (PhotoModel * ( *)(Pvl & pvl)) p->GetPlugin(algorithm);
66 return (*plugin)(pvl);
67 }
68} // end namespace isis
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
static PhotoModel * Create(Pvl &pvl)
Create a PhotoModel 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