22#include "IException.h"
23#include "NaifStatus.h"
24#include "PvlKeyword.h"
53 _kernels = kernels._kernels;
54 _camVersion = kernels._camVersion;
77 if (
this != &kernels) {
79 _kernels = kernels._kernels;
80 _camVersion = kernels._camVersion;
122 for (
unsigned int i = 0 ; i < _kernels.size() ; i++) {
123 if (!_kernels[i].exists) nMissing++;
180 _kernels.push_back(
examine(kfile,
true));
239 ktotal_c(
"ALL", &count);
241 for (
int i = 0 ; i < count ; i++) {
244 SpiceChar source[128];
247 kdata_c(i,
"ALL",
sizeof(file),
sizeof(ktype),
sizeof(source),
248 file, ktype,source, &handle, &found);
249 if (found == SPICETRUE) {
250 _kernels.push_back(
examine(file,
false));
270 for (
unsigned int i = 0 ; i < _kernels.size() ; i++) {
271 _kernels[i].managed =
true;
289 for (
unsigned int i = 0 ; i < _kernels.size() ; i++) {
290 _kernels[i].managed =
false;
309 for (
unsigned int i = 0 ; i < _kernels.size() ; i++) {
310 if (!_kernels[i].managed)
return (
false);;
337 for (
unsigned int i = 0 ; i < _kernels.size() ; i++) {
338 _kernels[i].loaded =
false;
367 if (ktypes.isEmpty()) {
368 for (
unsigned int k = 0 ; k < _kernels.size() ; k++) {
369 if (
Load(_kernels[k])) { nLoaded++; }
375 for (
int t = 0 ; t < tlist.size() ; t++) {
376 for (
unsigned int k = 0; k < _kernels.size() ; k++) {
377 if (_kernels[k].ktype == tlist[t]) {
378 if (
Load(_kernels[k])) { nLoaded++; }
408 for (
unsigned int k = 0 ; k < _kernels.size() ; k++) {
409 if (
Load(_kernels[k])) { nLoaded++; }
427 for (
unsigned int i = 0 ; i < _kernels.size() ; i++) {
428 if (
UnLoad(_kernels[i])) nUnloaded++;
456 if (ktypes.isEmpty()) {
462 for (
int t = 0 ; t < tlist.size() ; t++) {
463 for (
unsigned int k = 0; k < _kernels.size() ; k++) {
464 if (_kernels[k].ktype == tlist[t]) {
465 if (
UnLoad(_kernels[k])) nUnloaded++;
493 for (
unsigned int i = 0 ; i < _kernels.size() ; i++) {
497 SpiceChar source[128];
502 kinfo_c(_kernels[i].fullpath.toLatin1().data(),
sizeof(ktype),
sizeof(source),
503 ktype,source, &handle, &found);
506 if (found == SPICETRUE) {
507 if (!_kernels[i].loaded) nchanged++;
508 _kernels[i].loaded =
true;
511 if (_kernels[i].loaded) nchanged++;
512 _kernels[i].loaded =
false;
541 for (
unsigned int i = 0 ; i < _kernels.size() ; i++) {
542 if (_kernels[i].loaded) {
543 _kernels[i].managed =
false;
547 _kernels[i].managed =
true;
601 for (
unsigned int i = 0 ; i < other._kernels.size() ; i++) {
605 kfile.managed =
false;
606 _kernels.push_back(kfile);
610 if (other._kernels[i].loaded) {
611 kernel->loaded =
true;
612 kernel->managed =
false;
653 for (
int i = 0 ; i < kmap.size() ; i++) {
654 types.append(kmap.key(i));
676 if (ktypes.isEmpty()) {
677 for (
unsigned int k = 0; k < _kernels.size() ; k++) {
678 flist.push_back(_kernels[k].pathname);
684 for (
int t = 0 ; t < tlist.size() ; t++) {
685 for (
unsigned int k = 0; k < _kernels.size() ; k++) {
686 if (_kernels[k].ktype == tlist[t]) {
687 flist.push_back(_kernels[k].pathname);
723 if (ktypes.isEmpty()) {
724 for (
unsigned int i = 0 ; i < _kernels.size() ; i++) {
725 if (_kernels[i].loaded) flist.push_back(_kernels[i].pathname);
730 for (
int t = 0 ; t < tlist.size() ; t++ ) {
731 for (
unsigned int k = 0; k < _kernels.size() ; k++) {
732 if (_kernels[k].ktype == tlist[t]) {
733 flist.push_back(_kernels[k].pathname);
754 for (
unsigned int i = 0 ; i < _kernels.size() ; i++) {
755 if (!_kernels[i].exists) flist.push_back(_kernels[i].pathname);
779 furnsh_c(kfile.fullpath.toLatin1().data());
782 kfile.managed =
true;
789 return (kfile.loaded);
816 bool wasLoaded(
false);
821 unload_c(kfile.fullpath.toLatin1().data());
827 kfile.loaded =
false;
868 for (
int k = 0 ; k < tlist.size() ; k++) {
882 copy(klist.begin(), klist.end(), back_inserter(_kernels));
904 const QString &kname,
905 const bool &manage) {
912 for (
int i = 0 ; i < kkey.size() ; i++) {
913 if (!kkey.isNull(i)) {
914 if (kkey[i].toLower() !=
"table") {
915 klist.push_back(
examine(kkey[i], manage));
950 KernelList::iterator klist;
951 for (klist = _kernels.begin() ; klist != _kernels.end() ; ++klist) {
952 if (klist->pathname == kfile) {
return (&(*klist)); }
953 if (klist->name == kfile) {
return (&(*klist)); }
954 if (klist->fullpath == kfile) {
return (&(*klist)); }
970 for (
unsigned int i = 0 ; i < _kernels.size() ; i++) {
972 if (ktypes.exists(_kernels[i].ktype)) {
973 ktypes.get(_kernels[i].ktype).push_back(kfile);
976 ktypes.add(_kernels[i].ktype, KernelFileList(1, kfile));
992 if (ktype.toUpper() ==
"UNKNOWN")
return (
false);
993 if (ktype.toUpper() ==
"DEM")
return (
false);
1045 const bool &manage)
const {
1049 kf.pathname = kfile;
1050 kf.name = kernfile.name();
1051 kf.fullpath = kernfile.expanded();
1052 kf.exists = kernfile.fileExists();
1053 kf.ktype =
"UNKNOWN";
1055 kf.managed = manage;
1063 SpiceChar ktype[32];
1064 SpiceChar source[128];
1069 kinfo_c(kf.fullpath.toLatin1().data(),
sizeof(ktype),
sizeof(source), ktype,
1070 source, &handle, &found);
1073 if (found == SPICETRUE) {
1110 QString kpath = kernFile.expanded();
1111 ifstream ifile(kpath.toLatin1().data(), ios::in | ios::binary);
1112 QString ktype(
"UNKNOWN");
1115 ifile.read(ibuf, 8);
1117 for (
int i = 0 ; i < 8 ; i++)
1118 if (ibuf[i] ==
'\n') ibuf[i] =
'\0';
1123 if (istr.contains(
"/")) {
1124 ktype = istr.split(
"/").last();
1128 if ((ktype ==
"UNKNOWN") || (ktype ==
"DAF")) {
1182 const QString &iktype)
const {
1184 QString ktype(iktype);
1194 else if (ext ==
"ti") {
1198 string::size_type idx = base.find(
"addendum");
1199 if (idx != string::npos) {
1203 else if (ext ==
"tsc") {
1206 else if (ext ==
"tf") {
1209 else if (ext ==
"tls") {
1212 else if (ext ==
"tpc") {
1215 else if (ext ==
"bc") {
1218 else if (ext ==
"bsp") {
1221 else if (ext ==
"bes") {
1224 else if (ext ==
"bds") {
1227 else if (ext ==
"meta") {
IO Handler for Isis Cubes.
Pvl * label() const
Returns a pointer to the IsisLabel object associated with the cube.
File name manipulation and expansion.
Adds specific functionality to C++ strings.
int ToInteger() const
Returns the object string as an integer.
IString Trim(const std::string &chars)
Removes characters from the beginning and end of the IString.
IString UpCase()
Converst any lower case characters in the object IString with uppercase characters.
IString DownCase()
Converts all upper case letters in the object IString into lower case characters.
QString ToQt() const
Retuns the object string as a QString.
Determine SPICE kernels defined in an ISIS file.
int UpdateManagedStatus()
Update the managed state of the kernel file list.
void InitializeNaifKernelPool()
Initialize the NAIF kernel keeper pool.
bool Add(const QString &kfile)
Add a new kernel to the list.
bool IsNaifType(const QString &ktype) const
Determine if the type is a NAIF supported kernel type.
void Manage()
Set each kernels management status to managed.
KernelFile examine(const QString &fname, const bool &manage=true) const
Determine type of NAIF kernel file.
int Discover()
Determine which NAIF kernels are currently loaded in the pool.
int getCameraVersion(Pvl &pvl) const
Determine the ISIS camera model version number.
int UpdateLoadStatus()
Determine the load status of all kernels known to this object.
QStringList getTypes(const QString &ktypes) const
Get a vector of comma separated types from a string.
KernelFile * findByName(const QString &kfile)
Search kernel file list of a particular pattern.
void Init(Pvl &pvl)
Determine Spice kernels in an ISIS label.
QString resolveType(const QString &kfile) const
Determines type of NAIF/ISIS kernel we're dealing with.
Kernels()
Default Constructor.
QStringList getKernelList(const QString &ktype="") const
Provide a list of all the kernels found.
QString resolveTypeByExt(const QString &kfile, const QString &iktype="UNKNOWN") const
Check kernel type by file extension and special ISIS kernels.
void Clear()
Remove all kernel files from internal list.
void addKernels(const KernelList &klist)
Add a list of kernel files to internal storage.
QStringList getLoadedList(const QString &ktypes="") const
Returns list of kernel currently loaded according to status.
int Missing() const
Return count of missing kernel files.
bool IsManaged() const
Determine if all kernels are managed by this object.
TypeList categorizeByType() const
Categorizes the kernel list by type.
std::vector< KernelFile > findKernels(Pvl &pvl, const QString &kname, const bool &manage=true)
Retrieve contents of keyword.
int UnLoad()
Unloads all kernels from the NAIF pool.
QStringList getMissingList() const
Returns list of kernels that were not found to exist.
int Merge(const Kernels &other)
Merge the contents of another Kernels object.
int Load()
Load all kernels in list.
QStringList getKernelTypes() const
Return list of types in kernel list.
Kernels & operator=(const Kernels &kernels)
Copy constructor for existing Kernels objecr.
void UnManage()
Set each kernels' management state to unmanaged.
static void CheckErrors(bool resetNaif=true)
This method looks for any naif errors that might have occurred.
bool hasKeyword(const QString &name) const
Check to see if a keyword exists.
Contains multiple PvlContainers.
Container for cube-like labels.
A single keyword-value pair.
@ Traverse
Search child objects.
This is free and unencumbered software released into the public domain.
Namespace for the standard library.