Isis Developer Reference
Kernels.h
Go to the documentation of this file.
1 #ifndef Kernels_h
2 #define Kernels_h
3 
8 /* SPDX-License-Identifier: CC0-1.0 */
9 
10 #include <iostream>
11 #include <string>
12 #include <vector>
13 
14 #include "Camera.h"
15 #include "Cube.h"
16 #include "CollectorMap.h"
17 #include "IException.h"
18 #include "Pvl.h"
19 
20 namespace Isis {
21 
94 class Kernels {
95  public:
97  Kernels();
98  Kernels(const Kernels &kernels);
99  Kernels(const QString &filename);
100  Kernels(Cube &cube);
101  Kernels(Pvl &pvl);
103  virtual ~Kernels() { UnLoad(); }
104 
105  Kernels &operator=(const Kernels &kernels);
106 
108  int size() const { return (_kernels.size()); }
109  int Missing() const;
110 
111  void Init(Pvl &pvl);
112  bool Add(const QString &kfile);
113 
114  void Clear();
115  int Discover();
116 
117  void Manage();
118  void UnManage();
119  bool IsManaged() const;
120 
122 
123  int Load(const QString &ktype);
124  int Load();
125 
126  int UnLoad(const QString &ktype);
127  int UnLoad();
128 
129  int UpdateLoadStatus();
130 
131  int Merge(const Kernels &other);
132 
133  QStringList getKernelTypes() const;
134  QStringList getKernelList(const QString &ktype = "")
135  const;
136  QStringList getLoadedList(const QString &ktypes = "")
137  const;
138  QStringList getMissingList() const;
139 
140 
142  int CameraVersion() const { return (_camVersion); }
143 
144  private:
145  struct KernelFile {
146  QString pathname;
147  QString name;
148  QString fullpath;
149  bool exists;
150  QString ktype;
151  mutable bool loaded;
152  bool managed;
153  };
154 
155  typedef std::vector<KernelFile> KernelList;
156  KernelList _kernels;
157  int _camVersion;
158 
159  typedef std::vector<KernelFile *> KernelFileList;
160  typedef CollectorMap<QString, KernelFileList> TypeList;
161 
162  bool Load(KernelFile &kfile);
163  bool UnLoad(KernelFile &kfile);
164 
165  QStringList getTypes(const QString &ktypes) const;
166  QString resolveType(const QString &kfile) const;
167  QString resolveTypeByExt(const QString &kfile,
168  const QString &iktype = "UNKNOWN") const;
169 
170  bool IsNaifType(const QString &ktype) const;
171  KernelFile examine(const QString &fname, const bool &manage = true)
172  const;
173  int UpdateManagedStatus();
174  std::vector<KernelFile> findKernels(Pvl &pvl, const QString &kname,
175  const bool &manage = true);
176  KernelFile *findByName(const QString &kfile);
177  TypeList categorizeByType() const;
178 
179  void addKernels(const KernelList &klist);
180  QString getKernelType(const QString &kname) const;
181  void loadKernel(const QString &ktype = "");
182  int getCameraVersion(Pvl &pvl) const;
183 
184 };
185 
186 } // namespace Isis
187 #endif
188 
189 
Isis::Kernels::size
int size() const
Returns the number of kernels found and/or loaded.
Definition: Kernels.h:108
FileName.h
Isis::Kernels::UnLoad
int UnLoad()
Unloads all kernels from the NAIF pool.
Definition: Kernels.cpp:425
Cube.h
Isis::Kernels
Determine SPICE kernels defined in an ISIS file.
Definition: Kernels.h:94
Isis::Kernels::Merge
int Merge(const Kernels &other)
Merge the contents of another Kernels object.
Definition: Kernels.cpp:599
Isis::Kernels::IsManaged
bool IsManaged() const
Determine if all kernels are managed by this object.
Definition: Kernels.cpp:308
Isis::Kernels::Manage
void Manage()
Set each kernels management status to managed.
Definition: Kernels.cpp:269
Isis::Kernels::operator=
Kernels & operator=(const Kernels &kernels)
Copy constructor for existing Kernels objecr.
Definition: Kernels.cpp:76
Isis::Kernels::Discover
int Discover()
Determine which NAIF kernels are currently loaded in the pool.
Definition: Kernels.cpp:235
Isis::Kernels::getKernelTypes
QStringList getKernelTypes() const
Return list of types in kernel list.
Definition: Kernels.cpp:650
Isis::Kernels::getLoadedList
QStringList getLoadedList(const QString &ktypes="") const
Returns list of kernel currently loaded according to status.
Definition: Kernels.cpp:720
Isis::CollectorMap::size
int size() const
Returns the size of the collection.
Definition: CollectorMap.h:512
NaifStatus.h
Isis::Kernels::Load
int Load()
Load all kernels in list.
Definition: Kernels.cpp:405
Isis::Pvl
Container for cube-like labels.
Definition: Pvl.h:119
Isis::Kernels::UnManage
void UnManage()
Set each kernels' management state to unmanaged.
Definition: Kernels.cpp:288
Isis::Kernels::getKernelList
QStringList getKernelList(const QString &ktype="") const
Provide a list of all the kernels found.
Definition: Kernels.cpp:672
QStringList
Isis::Kernels::Clear
void Clear()
Remove all kernel files from internal list.
Definition: Kernels.cpp:195
Isis::Kernels::Add
bool Add(const QString &kfile)
Add a new kernel to the list.
Definition: Kernels.cpp:178
Isis::Kernels::InitializeNaifKernelPool
void InitializeNaifKernelPool()
Initialize the NAIF kernel keeper pool.
Definition: Kernels.cpp:333
Pvl.h
Isis::CollectorMap::key
const K & key(int nth) const
Returns the nth key in the collection.
Definition: CollectorMap.h:673
Isis::Kernels::~Kernels
virtual ~Kernels()
Destructor always unloads the kernels from the pool.
Definition: Kernels.h:103
Isis::Kernels::CameraVersion
int CameraVersion() const
Returns the ISIS camera model version number.
Definition: Kernels.h:142
Isis::Cube
IO Handler for Isis Cubes.
Definition: Cube.h:167
Isis::Kernels::Missing
int Missing() const
Return count of missing kernel files.
Definition: Kernels.cpp:120
Camera.h
IException.h
std
Namespace for the standard library.
CollectorMap.h
Isis::CollectorMap
Collector/container for arbitrary items.
Definition: CollectorMap.h:419
Isis::Cube::label
Pvl * label() const
Returns a pointer to the IsisLabel object associated with the cube.
Definition: Cube.cpp:1701
PvlKeyword.h
Isis::Kernels::getMissingList
QStringList getMissingList() const
Returns list of kernels that were not found to exist.
Definition: Kernels.cpp:752
Isis::Kernels::Init
void Init(Pvl &pvl)
Determine Spice kernels in an ISIS label.
Definition: Kernels.cpp:142
Isis::Kernels::Kernels
Kernels()
Default Constructor.
Definition: Kernels.cpp:32
Kernels.h
Isis
This is free and unencumbered software released into the public domain.
Definition: Apollo.h:16
Isis::Kernels::UpdateLoadStatus
int UpdateLoadStatus()
Determine the load status of all kernels known to this object.
Definition: Kernels.cpp:491