69 Kernels::Kernels(
const Kernels &kernels) {
70 _kernels = kernels._kernels;
71 _camVersion = kernels._camVersion;
73 UpdateManagedStatus();
94 if (
this != &kernels) {
96 _kernels = kernels._kernels;
97 _camVersion = kernels._camVersion;
99 UpdateManagedStatus();
109 Kernels::Kernels(
const QString &filename) {
128 Kernels::Kernels(
Pvl &pvl) {
137 int Kernels::Missing()
const {
139 for (
unsigned int i = 0 ; i < _kernels.size() ; i++) {
140 if (!_kernels[i].exists) nMissing++;
159 void Kernels::Init(
Pvl &pvl) {
162 addKernels(findKernels(pvl,
"TargetPosition"));
163 addKernels(findKernels(pvl,
"InstrumentPosition"));
164 addKernels(findKernels(pvl,
"InstrumentPointing"));
165 addKernels(findKernels(pvl,
"Frame"));
166 addKernels(findKernels(pvl,
"TargetAttitudeShape"));
167 addKernels(findKernels(pvl,
"Instrument"));
168 addKernels(findKernels(pvl,
"InstrumentAddendum"));
169 addKernels(findKernels(pvl,
"LeapSecond"));
170 addKernels(findKernels(pvl,
"SpacecraftClock"));
171 addKernels(findKernels(pvl,
"ShapeModel"));
172 addKernels(findKernels(pvl,
"Extra"));
173 _camVersion = getCameraVersion(pvl);
195 bool Kernels::Add(
const QString &kfile) {
196 if (!findByName(kfile)) {
197 _kernels.push_back(examine(kfile,
true));
212 void Kernels::Clear() {
252 int Kernels::Discover() {
255 NaifStatus::CheckErrors();
256 ktotal_c(
"ALL", &count);
258 for (
int i = 0 ; i < count ; i++) {
261 SpiceChar source[128];
264 kdata_c(i,
"ALL",
sizeof(file),
sizeof(ktype),
sizeof(source),
265 file, ktype,source, &handle, &found);
266 if (found == SPICETRUE) {
267 _kernels.push_back(examine(file,
false));
271 NaifStatus::CheckErrors();
286 void Kernels::Manage() {
287 for (
unsigned int i = 0 ; i < _kernels.size() ; i++) {
288 _kernels[i].managed =
true;
305 void Kernels::UnManage() {
306 for (
unsigned int i = 0 ; i < _kernels.size() ; i++) {
307 _kernels[i].managed =
false;
325 bool Kernels::IsManaged()
const {
326 for (
unsigned int i = 0 ; i < _kernels.size() ; i++) {
327 if (!_kernels[i].managed)
return (
false);;
350 void Kernels::InitializeNaifKernelPool() {
351 NaifStatus::CheckErrors();
353 NaifStatus::CheckErrors();
354 for (
unsigned int i = 0 ; i < _kernels.size() ; i++) {
355 _kernels[i].loaded =
false;
381 int Kernels::Load(
const QString &ktypes) {
384 if (ktypes.isEmpty()) {
385 for (
unsigned int k = 0 ; k < _kernels.size() ; k++) {
386 if (Load(_kernels[k])) { nLoaded++; }
392 for (
int t = 0 ; t < tlist.size() ; t++) {
393 for (
unsigned int k = 0; k < _kernels.size() ; k++) {
394 if (_kernels[k].ktype == tlist[t]) {
395 if (Load(_kernels[k])) { nLoaded++; }
422 int Kernels::Load() {
425 for (
unsigned int k = 0 ; k < _kernels.size() ; k++) {
426 if (Load(_kernels[k])) { nLoaded++; }
442 int Kernels::UnLoad() {
444 for (
unsigned int i = 0 ; i < _kernels.size() ; i++) {
445 if (UnLoad(_kernels[i])) nUnloaded++;
470 int Kernels::UnLoad(
const QString &ktypes) {
473 if (ktypes.isEmpty()) {
474 nUnloaded = UnLoad();
479 for (
int t = 0 ; t < tlist.size() ; t++) {
480 for (
unsigned int k = 0; k < _kernels.size() ; k++) {
481 if (_kernels[k].ktype == tlist[t]) {
482 if (UnLoad(_kernels[k])) nUnloaded++;
508 int Kernels::UpdateLoadStatus() {
510 for (
unsigned int i = 0 ; i < _kernels.size() ; i++) {
512 if (IsNaifType(_kernels[i].ktype)) {
514 SpiceChar source[128];
518 NaifStatus::CheckErrors();
519 kinfo_c(_kernels[i].fullpath.toLatin1().data(),
sizeof(ktype),
sizeof(source),
520 ktype,source, &handle, &found);
521 NaifStatus::CheckErrors();
523 if (found == SPICETRUE) {
524 if (!_kernels[i].loaded) nchanged++;
525 _kernels[i].loaded =
true;
528 if (_kernels[i].loaded) nchanged++;
529 _kernels[i].loaded =
false;
556 int Kernels::UpdateManagedStatus() {
558 for (
unsigned int i = 0 ; i < _kernels.size() ; i++) {
559 if (_kernels[i].loaded) {
560 _kernels[i].managed =
false;
564 _kernels[i].managed =
true;
618 for (
unsigned int i = 0 ; i < other._kernels.size() ; i++) {
619 KernelFile *kernel = findByName(other._kernels[i].fullpath);
622 kfile.managed =
false;
623 _kernels.push_back(kfile);
627 if (other._kernels[i].loaded) {
628 kernel->loaded =
true;
629 kernel->managed =
false;
670 for (
int i = 0 ; i < kmap.
size() ; i++) {
671 types.append(kmap.
key(i));
693 if (ktypes.isEmpty()) {
694 for (
unsigned int k = 0; k < _kernels.size() ; k++) {
695 flist.push_back(_kernels[k].pathname);
701 for (
int t = 0 ; t < tlist.size() ; t++) {
702 for (
unsigned int k = 0; k < _kernels.size() ; k++) {
703 if (_kernels[k].ktype == tlist[t]) {
704 flist.push_back(_kernels[k].pathname);
740 if (ktypes.isEmpty()) {
741 for (
unsigned int i = 0 ; i < _kernels.size() ; i++) {
742 if (_kernels[i].loaded) flist.push_back(_kernels[i].pathname);
747 for (
int t = 0 ; t < tlist.size() ; t++ ) {
748 for (
unsigned int k = 0; k < _kernels.size() ; k++) {
749 if (_kernels[k].ktype == tlist[t]) {
750 flist.push_back(_kernels[k].pathname);
771 for (
unsigned int i = 0 ; i < _kernels.size() ; i++) {
772 if (!_kernels[i].exists) flist.push_back(_kernels[i].pathname);
792 if (IsNaifType(kfile.ktype)) {
794 NaifStatus::CheckErrors();
796 furnsh_c(kfile.fullpath.toLatin1().data());
797 NaifStatus::CheckErrors();
799 kfile.managed =
true;
806 return (kfile.loaded);
833 bool wasLoaded(
false);
836 NaifStatus::CheckErrors();
838 unload_c(kfile.fullpath.toLatin1().data());
839 NaifStatus::CheckErrors();
844 kfile.loaded =
false;
885 for (
int k = 0 ; k < tlist.size() ; k++) {
898 void Kernels::addKernels(
const KernelList &klist) {
899 copy(klist.begin(), klist.end(), back_inserter(_kernels));
920 Kernels::KernelList Kernels::findKernels(
Pvl &pvl,
921 const QString &kname,
922 const bool &manage) {
929 for (
int i = 0 ; i < kkey.
size() ; i++) {
931 if (kkey[i].toLower() !=
"table") {
932 klist.push_back(examine(kkey[i], manage));
967 KernelList::iterator klist;
968 for (klist = _kernels.begin() ; klist != _kernels.end() ; ++klist) {
969 if (klist->pathname == kfile) {
return (&(*klist)); }
970 if (klist->name == kfile) {
return (&(*klist)); }
971 if (klist->fullpath == kfile) {
return (&(*klist)); }
987 for (
unsigned int i = 0 ; i < _kernels.size() ; i++) {
989 if (ktypes.
exists(_kernels[i].ktype)) {
990 ktypes.
get(_kernels[i].ktype).push_back(kfile);
993 ktypes.
add(_kernels[i].ktype, KernelFileList(1, kfile));
1008 bool Kernels::IsNaifType(
const QString &ktype)
const {
1009 if (ktype.toUpper() ==
"UNKNOWN")
return (
false);
1010 if (ktype.toUpper() ==
"DEM")
return (
false);
1062 const bool &manage)
const {
1066 kf.pathname = kfile;
1067 kf.name = kernfile.
name();
1070 kf.ktype =
"UNKNOWN";
1072 kf.managed = manage;
1076 kf.ktype = resolveType(kf.fullpath);
1079 if (IsNaifType(kf.ktype)) {
1080 SpiceChar ktype[32];
1081 SpiceChar source[128];
1085 NaifStatus::CheckErrors();
1086 kinfo_c(kf.fullpath.toLatin1().data(),
sizeof(ktype),
sizeof(source), ktype,
1087 source, &handle, &found);
1088 NaifStatus::CheckErrors();
1090 if (found == SPICETRUE) {
1125 QString Kernels::resolveType(
const QString &kfile)
const {
1127 QString kpath = kernFile.
expanded();
1128 ifstream ifile(kpath.toLatin1().data(), ios::in | ios::binary);
1129 QString ktype(
"UNKNOWN");
1132 ifile.read(ibuf, 8);
1134 for (
int i = 0 ; i < 8 ; i++)
1135 if (ibuf[i] ==
'\n') ibuf[i] =
'\0';
1140 if (istr.contains(
"/")) {
1141 ktype = istr.split(
"/").last();
1145 if ((ktype ==
"UNKNOWN") || (ktype ==
"DAF")) {
1146 ktype = resolveTypeByExt(kfile, ktype);
1198 QString Kernels::resolveTypeByExt(
const QString &kfile,
1199 const QString &iktype)
const {
1201 QString ktype(iktype);
1211 else if (ext ==
"ti") {
1215 string::size_type idx = base.find(
"addendum");
1216 if (idx != string::npos) {
1220 else if (ext ==
"tsc") {
1223 else if (ext ==
"tf") {
1226 else if (ext ==
"tls") {
1229 else if (ext ==
"tpc") {
1232 else if (ext ==
"bc") {
1235 else if (ext ==
"bsp") {
1238 else if (ext ==
"bes") {
1241 else if (ext ==
"bds") {
1244 else if (ext ==
"meta") {
1265 int Kernels::getCameraVersion(
Pvl &pvl)
const {
bool hasKeyword(const QString &name) const
Check to see if a keyword exists.
PvlGroupIterator findGroup(const QString &name, PvlGroupIterator beg, PvlGroupIterator end)
Find a group with the specified name, within these indexes.
T & get(const K &key)
Returns the value associated with the name provided.
File name manipulation and expansion.
Namespace for the standard library.
Determine SPICE kernels defined in an ISIS file.
QString name() const
Returns the name of the file excluding the path and the attributes in the file name.
int ToInteger() const
Returns the object string as an integer.
int size() const
Returns the size of the collection.
const K & key(int nth) const
Returns the nth key in the collection.
int size() const
Returns the number of values stored in this keyword.
Contains multiple PvlContainers.
bool exists(const K &key) const
Checks the existance of a particular key in the list.
void add(const K &key, const T &value)
Adds the element to the list.
A single keyword-value pair.
QString ToQt() const
Retuns the object string as a QString.
QString expanded() const
Returns a QString of the full file name including the file path, excluding the attributes.
bool isNull(const int index=0) const
Decides whether a value is null or not at a given index.
Collector/container for arbitrary items.
Container for cube-like labels.
QString baseName() const
Returns the name of the file without the path and without extensions.
Pvl * label() const
Returns a pointer to the IsisLabel object associated with the cube.
Adds specific functionality to C++ strings.
Namespace for ISIS/Bullet specific routines.
QString extension() const
Returns the last extension of the file name.
IString UpCase()
Converst any lower case characters in the object IString with uppercase characters.
bool fileExists() const
Returns true if the file exists; false otherwise.
IString Trim(const std::string &chars)
Removes characters from the beginning and end of the IString.
IO Handler for Isis Cubes.