Isis 3 Programmer Reference
Isis::Kernels Class Reference

Determine SPICE kernels defined in an ISIS file. More...

#include <Kernels.h>

Collaboration diagram for Isis::Kernels:
Collaboration graph

Classes

struct  KernelFile
 

Public Member Functions

 Kernels ()
 Default Constructor. More...
 
 Kernels (const Kernels &kernels)
 Initialize new Kernels from state of existing one. More...
 
 Kernels (const QString &filename)
 Construct using an ISIS file name. More...
 
 Kernels (Cube &cube)
 Construct using an ISIS Cube object. More...
 
 Kernels (Pvl &pvl)
 Construct from an ISIS label. More...
 
virtual ~Kernels ()
 Destructor always unloads the kernels from the pool. More...
 
Kernelsoperator= (const Kernels &kernels)
 Copy constructor for existing Kernels objecr. More...
 
int size () const
 Returns the number of kernels found and/or loaded. More...
 
int Missing () const
 Return count of missing kernel files. More...
 
void Init (Pvl &pvl)
 Determine Spice kernels in an ISIS label. More...
 
bool Add (const QString &kfile)
 Add a new kernel to the list. More...
 
void Clear ()
 Remove all kernel files from internal list. More...
 
int Discover ()
 Determine which NAIF kernels are currently loaded in the pool. More...
 
void Manage ()
 Set each kernels management status to managed. More...
 
void UnManage ()
 Set each kernels' management state to unmanaged. More...
 
bool IsManaged () const
 Determine if all kernels are managed by this object. More...
 
void InitializeNaifKernelPool ()
 Initialize the NAIF kernel keeper pool. More...
 
int Load (const QString &ktype)
 Load all kernels with one more types. More...
 
int Load ()
 Load all kernels in list. More...
 
int UnLoad (const QString &ktype)
 Unloads all kernels of a specific type. More...
 
int UnLoad ()
 Unloads all kernels from the NAIF pool. More...
 
int UpdateLoadStatus ()
 Determine the load status of all kernels known to this object. More...
 
int Merge (const Kernels &other)
 Merge the contents of another Kernels object. More...
 
QStringList getKernelTypes () const
 Return list of types in kernel list. More...
 
QStringList getKernelList (const QString &ktype="") const
 Provide a list of all the kernels found. More...
 
QStringList getLoadedList (const QString &ktypes="") const
 Returns list of kernel currently loaded according to status. More...
 
QStringList getMissingList () const
 Returns list of kernels that were not found to exist. More...
 
int CameraVersion () const
 Returns the ISIS camera model version number. More...
 

Private Types

typedef std::vector< KernelFileKernelList
 
typedef std::vector< KernelFile * > KernelFileList
 
typedef CollectorMap< QString, KernelFileList > TypeList
 

Private Member Functions

bool Load (KernelFile &kfile)
 Load a kernel file. More...
 
bool UnLoad (KernelFile &kfile)
 Unloads a kernel from the NAIF kernel pool. More...
 
QStringList getTypes (const QString &ktypes) const
 Get a vector of comma separated types from a string. More...
 
QString resolveType (const QString &kfile) const
 Determines type of NAIF/ISIS kernel we're dealing with. More...
 
QString resolveTypeByExt (const QString &kfile, const QString &iktype="UNKNOWN") const
 Check kernel type by file extension and special ISIS kernels. More...
 
bool IsNaifType (const QString &ktype) const
 Determine if the type is a NAIF supported kernel type. More...
 
KernelFile examine (const QString &fname, const bool &manage=true) const
 Determine type of NAIF kernel file. More...
 
int UpdateManagedStatus ()
 Update the managed state of the kernel file list. More...
 
std::vector< KernelFilefindKernels (Pvl &pvl, const QString &kname, const bool &manage=true)
 Retrieve contents of keyword. More...
 
KernelFilefindByName (const QString &kfile)
 Search kernel file list of a particular pattern. More...
 
TypeList categorizeByType () const
 Categorizes the kernel list by type. More...
 
void addKernels (const KernelList &klist)
 Add a list of kernel files to internal storage. More...
 
QString getKernelType (const QString &kname) const
 
void loadKernel (const QString &ktype="")
 
int getCameraVersion (Pvl &pvl) const
 Determine the ISIS camera model version number. More...
 

Private Attributes

KernelList _kernels
 
int _camVersion
 

Detailed Description

Determine SPICE kernels defined in an ISIS file.

This class determines all SPICE kernels associated with an ISIS cube file and optionally/selectively loads them using the NAIF toolkit. This creates the kernel pool as it was when spiceinit determined all the kernels and it initialized the file for geometric operations.

Note that because NAIF kernel management is global in nature, careful thought and planning should preceed use of this class. You can get yourself into trouble if you take over management of kernels and inadvertantly unload them without regard for use by other resources. Methods are provided in this implementation to help minimize problems related to management of this global resource.

Note that ISIS caches some of the voluminous NAIF kernels, extracting only what is required from the SPK and CK (generally) kernels for a given observation. After this occurs, these kernels are no longer loaded by the ISIS Spice class hierarchy. This class provides that environment so that further NAIF operations can occur, such as velocity vector and instrument timing manipulations.

This class can be used instead of instantiating an ISIS Spice object. The recommended usage is as follows:

Cube cube;
cube.Open("mycube.cub");
Kernels myKernels(cube);
myKernels.UpdateLoadStatus(); // Ensures loaded kernels stay loaded
myKernels.Load();
. . .
// After manipulating the CK Spice data...
myKernels.UnLoad();

The implications of this code segment are: 1) All the kernels pertinent to an individual ISIS file are identified upon Kernels instantiation, 2) their load status is determined using the UpdateLoadStatus() method, 3) kernels already loaded are flagged as unmanaged, meaning they cannot be unloaded unless management is an explicit "hostile takeover" provided via the Manage() method (don't do it unless you absolutely have to), 4) after checking load status, and kernels you load are managed by your instantiation, and 5) when you UnLoad() or the object is destroyed, all managed kernels are unloaded - unmanaged kernels are not unloaded.

This class can be used in lieu of the Spice class with liberal use of the UpdateLoadStatus() and Discover() methods of this class.

It is possible to double load NAIF kernels, so be sure to maintain load status via UpdateLoadStatus() and proper usage techniques.

Author
2010-12-28 Kris Becker
History:

2010-12-29 Kris Becker - added resolveTypeByExt() method to find non-compliant NAIF file type identifiers kernels

2011-02-07 Kris Becker Corrected typo in Kernels/Extra (was Extras)

2011-02-28 Kris Becker - When using the examine() method, if the kernel is found to be loaded, its management state is set to unmanaged

2011-03-27 Kris Becker - Added copy constructor and assignment operator

2015-03-05 Kris Becker - Added support for DSK and meta kernels types. References #2035

2015-07-21 Kristin Berry - Added NaifStatus::CheckErrors() to see if any NAIF errors were signaled. References #2248.

Definition at line 111 of file Kernels.h.

Constructor & Destructor Documentation

◆ Kernels() [1/5]

Isis::Kernels::Kernels ( )

Default Constructor.

Default constructor simple initialization.

Definition at line 49 of file Kernels.cpp.

◆ Kernels() [2/5]

Isis::Kernels::Kernels ( const Kernels kernels)

Initialize new Kernels from state of existing one.

Initialize new Kernels object from the state of an existing one while preserving the state of one copied. Each kernel file state is copied to this new one. It ensures that ones that are already opened are set to an unmanaged state from the source. It also checks the current open state and will set ones found to be open as unmanaged as well. All other kernels files can be managed by this new instance.

Author
kbecker (3/26/2011)
Parameters
kernelsSource kernels object

Definition at line 69 of file Kernels.cpp.

◆ Kernels() [3/5]

Isis::Kernels::Kernels ( const QString &  filename)

Construct using an ISIS file name.

Parameters
filenameName of ISIS cube file

Definition at line 109 of file Kernels.cpp.

◆ Kernels() [4/5]

Isis::Kernels::Kernels ( Cube cube)

Construct using an ISIS Cube object.

Parameters
cubeCube object of ISIS file

Definition at line 119 of file Kernels.cpp.

References Isis::Cube::label().

◆ Kernels() [5/5]

Isis::Kernels::Kernels ( Pvl pvl)

Construct from an ISIS label.

Parameters
pvlISIS label to get kernel information from

Definition at line 128 of file Kernels.cpp.

◆ ~Kernels()

virtual Isis::Kernels::~Kernels ( )
inlinevirtual

Destructor always unloads the kernels from the pool.

Definition at line 120 of file Kernels.h.

References UnLoad().

Member Function Documentation

◆ Add()

bool Isis::Kernels::Add ( const QString &  kfile)

Add a new kernel to the list.

This method is provided to add individual NAIF kernels directly. Files names must contain a path to the file. ISIS "shortcuts" as defined in the DataDirectory group in the IsisPreferences files (e.g., "$base/kernels/lsk/naif0009.tls") are supported as well.

Note that if the file already exists, it is not added. This situation is indicated with a return value of false.

Files added in this way are set to manageable status.

Parameters
kfileName of kernel file to add with valid directory path
Returns
bool True if the files was added to the list, false if it already exists

Definition at line 195 of file Kernels.cpp.

Referenced by Isis::PushFrameCameraCcdLayout::addKernel().

◆ addKernels()

void Isis::Kernels::addKernels ( const KernelList &  klist)
private

Add a list of kernel files to internal storage.

Specialized inserter of images into exist container.

Parameters
klistList to add to existing collection

Definition at line 898 of file Kernels.cpp.

◆ CameraVersion()

int Isis::Kernels::CameraVersion ( ) const
inline

Returns the ISIS camera model version number.

Definition at line 159 of file Kernels.h.

◆ categorizeByType()

Kernels::TypeList Isis::Kernels::categorizeByType ( ) const
private

Categorizes the kernel list by type.

This method creates essentially a kernel type map with a pointer list to each KernelFile structure of that type.

Returns
Kernels::TypeList Kernel type list map of kernel file pointers

Definition at line 985 of file Kernels.cpp.

References Isis::CollectorMap< K, T, ComparePolicy, RemovalPolicy, CopyPolicy >::add(), Isis::CollectorMap< K, T, ComparePolicy, RemovalPolicy, CopyPolicy >::exists(), and Isis::CollectorMap< K, T, ComparePolicy, RemovalPolicy, CopyPolicy >::get().

◆ Clear()

void Isis::Kernels::Clear ( )

Remove all kernel files from internal list.

This method will clear out the kernel file list without any regard for its current state. This does not unload any kernels that are unloaded. One must Unload() prior to calling this method in order to gracefully close out the existing state of the kernel pool.

Definition at line 212 of file Kernels.cpp.

◆ Discover()

int Isis::Kernels::Discover ( )

Determine which NAIF kernels are currently loaded in the pool.

This method queries the NAIF KEEPER system/pool for all loaded kernels and adds them to the list in this object. It only knows about kernels that are loaded by the NAIF furnsh_c routine. If no kernels are loaded there will be no kernels discovered by this routine.

Upon entry into this method, the current list is discarded without unloading them. Hence, any kernels in this list are discard, whether they are loaded and managed by this class or not. If they are loaded according to the internal state as determined by previous activity in this class, and no additional NAIF activity has occured that unloads them, they should be found again by this method.

Note that ALL kernels discovered by this routine are marked as unmanaged, meaning you cannot unload the kernels without exerting management upon them via the Manage() method. See the Manage() documentation for more details and potential issues with this feature.

This method should not be used to update the load nature of an established kernel list. See the UpdateLoadStatus() method for this feature.

Here is a short coding example showing use of this method. It assumes there are some kernels already loaded (although it is entirely possible that no kernels are loaded). It will take over management of these kernels as well:

Kernels myKernels;
myKernels.Discover();
myKernels.Manage();
Returns
int Number of kernels discovered

Definition at line 252 of file Kernels.cpp.

Referenced by Isis::LightTimeCorrectionState::checkSpkKernelsForAberrationCorrection().

◆ examine()

Kernels::KernelFile Isis::Kernels::examine ( const QString &  kfile,
const bool &  manage = true 
) const
private

Determine type of NAIF kernel file.

This method will determine the type of kernel contained in the file specified by the kfile parameter.

The file specified by the kfile parameter is assumed to conform to NAIF kernel file conventions (i.e., binary kernels are created using the NAIF toolkit, text kernels conform to NAIF standards). There are, however, two exceptions that must be considered. ISIS DEMs are cubes and do not follow the NAIF convention for obvious reasons. ISIS IAK kernels also do not typically follow NAIF identification standards. These two cases are handled special.

To determine a NAIF standard conforming file type, the first eight characters of the file given will be inspected to determine the NAIF kernel type. If this fails to produce a known type, then it is assumed to be an ISIS DEM or IAK kernel.

For valid NAIF kernels, the NAIF routine kinfo_c is used to acquire additional information such as if it is loaded.

For files where the type cannot be determined, the type is set to "UNKNOWN". ISIS DEMs are set to the type "DEM". ISIS IAKs are set to "IAK". Other types are set as follows:

CK SPK DAF (may be SPKs) PCK EK META IK FK SCLK

Parameters
kfileName of kernel file to inspect
manageDefault state to assign to kernel. Note that this only retains effect if the kernel is not loaded. If it is loaded, its state is set to unmanaged. You must explicitly exert management upon kernels that are already loaded. Optional argument so the default is true.
Returns
Kernels::KernelFile An internal Kernels file structure describing the file.

Definition at line 1061 of file Kernels.cpp.

References Isis::FileName::expanded(), Isis::FileName::fileExists(), Isis::FileName::name(), Isis::IString::ToQt(), and Isis::IString::UpCase().

◆ findByName()

Kernels::KernelFile * Isis::Kernels::findByName ( const QString &  kfile)
private

Search kernel file list of a particular pattern.

This method will compare the file, kfile, to each kernel contained in the internal list and return a pointer to the internal file entry structure for it if it exists.

There are three possible forms of the filename that are maintained by this routine. The kernel name as extracted from the Kernels group in the label of an ISIS file. These filenames will typically have an ISIS "environment" variable included in the full file name, such as "$base/kernels/lsk/naif0009.tls". When a new file is added, the complete path is stripped off and just the base filename itself is stored, such as "naif0009.tls". The third form is the fully expanded version of the file, which may look like "/usgs/cpkgs/isis3/data/base/kernels/lsk/naif0009.tls". All three forms of the filename are checked and only one has to match.

Parameters
kfileName of file to find. It can be any one of the three stored forms.
Returns
Kernels::KernelFile* Pointer to structure containing associated with the name if it exists in the list, otherwise a 0 pointer is returned indicating it does not exist in the list

Definition at line 966 of file Kernels.cpp.

◆ findKernels()

Kernels::KernelList Isis::Kernels::findKernels ( Pvl pvl,
const QString &  kname,
const bool &  manage = true 
)
private

Retrieve contents of keyword.

This method retrieves the contents of a keyword. It is specifically designed to handle Kernel group keywords. As such, any value of "Table" found in the keyword is not added to the kernel list.

Parameters
pvlISIS label containing the Kernels group.
knameName of keyword to extract
manageDefault management state to assign to kernels. The default is to manage the kernels that are found. See examine() for full disclosure of how this is set.
Returns
Kernels::KernelList List of scrutinized kernel file names

Definition at line 920 of file Kernels.cpp.

References Isis::PvlObject::findGroup(), Isis::PvlContainer::hasKeyword(), Isis::PvlKeyword::isNull(), and Isis::PvlKeyword::size().

◆ getCameraVersion()

int Isis::Kernels::getCameraVersion ( Pvl pvl) const
private

Determine the ISIS camera model version number.

This method looks for the "CameraVersion" keyword in the Kernels group of an ISIS label. If found, it returns this number, otherwise it returns 0 (this is indicative of an older file).

Parameters
pvlISIS label
Returns
int The version number found in the label. If it cannot be determined, 0 is returned.

Definition at line 1265 of file Kernels.cpp.

References Isis::PvlObject::findGroup(), Isis::PvlContainer::hasKeyword(), and Isis::IString::ToInteger().

◆ getKernelList()

QStringList Isis::Kernels::getKernelList ( const QString &  ktypes = "") const

Provide a list of all the kernels found.

This method will return all the kernel file references as found in the ISIS label.

Parameters
ktypesOptional list of kernel types to return in the list. This can be any type found in the internal list as returned by getKernelTypes(). If empty, returns all kernels.
Returns
std::vector<QString> A vector of filenames of SPICE kernels

Definition at line 689 of file Kernels.cpp.

Referenced by Isis::LightTimeCorrectionState::checkSpkKernelsForAberrationCorrection(), Isis::RosettaVirtisCamera::hasArticulationKernel(), and Isis::DawnVirCamera::hasArticulationKernel().

◆ getKernelTypes()

QStringList Isis::Kernels::getKernelTypes ( ) const

Return list of types in kernel list.

This method determines what types of kernels are currently in the internal list and returns them in alphabetical order. An empty list is returned if there are no kernels. The list may contain "UNKNOWN" which is the default type assigned when the type of the kernel file cannot be determined. These kernels are excluded from any loading/unloading.

The list of known types are:

CK SPK DAF (synonymous for SPKs as well so load both) PCK EK META IK FK SCLK IAK (ISIS specific) DSK

Kernel types are determined by inspecting the first 8 characters of a kernel file and extracting the contents there. The actual type is the string value after the last '/' character. This is typically the value that is also returned by the NAIF kinfo_c utility.

Returns
std::vector<QString> Alphabetical list of kernel types

Definition at line 667 of file Kernels.cpp.

References Isis::CollectorMap< K, T, ComparePolicy, RemovalPolicy, CopyPolicy >::key(), and Isis::CollectorMap< K, T, ComparePolicy, RemovalPolicy, CopyPolicy >::size().

◆ getLoadedList()

QStringList Isis::Kernels::getLoadedList ( const QString &  ktypes = "") const

Returns list of kernel currently loaded according to status.

This method returns a list of kernel filenames that are loaded according to internal status. If the load status is in question, used UpdateLoadStatus() prior to calling this method.

Users can restrict the list to loaded kernels of a specific type. For example, to get a list of all CKs and SPKs loaded, the following code can be used:

mykernels.getLoadedList("CK,SPK");
Parameters
ktypesOptional string containing comma separated list of types to return if loaded. If empty, returns all types of kernels that are deemed loaded.
Returns
std::vector<QString> List of kernel filenames that are currently loaded.

Definition at line 737 of file Kernels.cpp.

◆ getMissingList()

QStringList Isis::Kernels::getMissingList ( ) const

Returns list of kernels that were not found to exist.

This method can be used to identify which kernels do not exist when they were added to this object. If the Missing() method returns a number > 0, then this routine returns a list of files missing.

Returns
std::vector<QString> List of missing kernel files

Definition at line 769 of file Kernels.cpp.

◆ getTypes()

QStringList Isis::Kernels::getTypes ( const QString &  ktypes) const
private

Get a vector of comma separated types from a string.

This method parses a string assumed to contain NAIF kernel file types. It will return a vector of strings that contain each type found in the string parameters, ktypes.

Validity of the types of values found here are not verified but can still be used effectively in other manipulation activities in this object.

Here is now the strings are used:

std::vector<QString> klist = myKernels.getTypes("LSK,FK,SPK"); for
(unsigned int i = 0 ; i < klist.size(I) ; i++) {
cout << i << ": " << klist[i] << endl;
}

This will result in out of the following:

0: LSK
1: FK
2: SPK
Parameters
ktypesSgtring containing comma separated list of kernel file types
Returns
std::vector<QString> Vector containing values between commas.

Definition at line 882 of file Kernels.cpp.

References Isis::IString::ToQt(), Isis::IString::Trim(), and Isis::IString::UpCase().

◆ Init()

void Isis::Kernels::Init ( Pvl pvl)

Determine Spice kernels in an ISIS label.

This method reads keywords in the Kernels group in the ISIS label hierarchy to find all the pertinent kernel files. They are found in the Kernels Group.

The order listed here is the same as the order specified in the ISIS Spice class at the time this class was written. When loading and unloading, the order is the same as is read in here.

Parameters
pvlAssumed to be a valid ISIS cube label containing the Kernels group

Definition at line 159 of file Kernels.cpp.

◆ InitializeNaifKernelPool()

void Isis::Kernels::InitializeNaifKernelPool ( )

Initialize the NAIF kernel keeper pool.

This method will thoroughly clear out the NAIF kernel keeper pool. This is done using the NAIF k_clear() utility. As the documentation states, it operates by side effects unloading all kernels and reinitializing the keeper pool.

This method has no regard at to whether any of the NAIF kernels are managed or not. It does update all kernels load status to unloaded.

NOTE: This method should be used with caution as it can have disasterous side effects for ISIS processing. Specifically, using this method arbitrarily will likely cause fatal exceptions particularly for Spice class instantiations.

Definition at line 350 of file Kernels.cpp.

◆ IsManaged()

bool Isis::Kernels::IsManaged ( ) const

Determine if all kernels are managed by this object.

This method will return true if all kernels listed in this object are marked as "managed". If any one of the kernels is found to have an unmanaged state, false will be returned by this routine.

Management/unmanagement is an all-or-nothing scheme.

Returns
bool True if all kernels are marked manageable, false if even one is not.

Definition at line 325 of file Kernels.cpp.

◆ IsNaifType()

bool Isis::Kernels::IsNaifType ( const QString &  ktype) const
private

Determine if the type is a NAIF supported kernel type.

Parameters
ktypeString containing the kernel type
Returns
bool True if it is a NAIF kernel type

Definition at line 1008 of file Kernels.cpp.

◆ Load() [1/3]

int Isis::Kernels::Load ( const QString &  ktypes)

Load all kernels with one more types.

This method will find all kernels with a specific type and loads them into the NAIF KEEPER system/pool using the NAIF furnsh_c utility. If they are already loaded, they are not loaded again. Status is set to show they are loaded.

This object cannot monitor the kernel pool unless explicit action is taken. See the CheckLoadStatus() method. It will update the load status of kernels in the current list.

NOTE: If individual kernel are not managed by this routine they are not loaded. Users must invoke the Manage() method to enable full kernel manipulation.

Parameters
ktypesOne or more kernel types specified in a comma separated list
Returns
int Number of kernels loaded

Definition at line 381 of file Kernels.cpp.

Referenced by Isis::PushFrameCameraCcdLayout::addKernel().

◆ Load() [2/3]

int Isis::Kernels::Load ( )

Load all kernels in list.

This method will iterate though all NAIF-type kernels and load them into the NAIF KEEPER system/pool using the NAIF furnsh_c utility. If they are already loaded, they are not loaded again. Status is set to show they are loaded.

This object cannot monitor the kernel pool unless explicit action is taken. See the CheckLoadStatus() method. It will update the load status of kernels in the current list.

NOTE: If individual kernel are not managed by this routine they are not loaded. Users must invoke the Manage() method to enable full kernel manipulation.

Returns
int Number of kernels loaded

Definition at line 422 of file Kernels.cpp.

◆ Load() [3/3]

bool Isis::Kernels::Load ( Kernels::KernelFile kfile)
private

Load a kernel file.

The internal file structure contains information related to a kernel that is common to the ISIS system. Its status is checked and only if the kernels is not loaded will it be loaded via the NAIF furnsh_c utility. Its load status is updated as well as its manage status (it becomes managed).

Parameters
kfileStructure containing the file to load
Returns
bool True if the file is loaded successfully, false if not. It may not be loaded for various reasons: it is not a NAIF type kernel or it failed to load due to errors or non-existance.

Definition at line 791 of file Kernels.cpp.

◆ Manage()

void Isis::Kernels::Manage ( )

Set each kernels management status to managed.

This method will change every kernels's management state to managed so that full manipulation of every kernel can be performed by this object.

If a kernel is managed, it will be allowed to UnLoad at will. This is typically the only restriction of an unmanaged kernel.

Definition at line 286 of file Kernels.cpp.

◆ Merge()

int Isis::Kernels::Merge ( const Kernels other)

Merge the contents of another Kernels object.

This method mergest the contents of another Kernels object into this one. Kernels that exist in both instances of the object are handled special. The status of this object's version of the file is updated to reflect conditions of the other objects kernels.

When the file does not exist in this object, the kernel file structure is copied from the other Kernels object, its managed status is set to false (since it pre-exists in another object that must relinquish its management of it) and is added to this objects kernel list.

When the file does exist in this object, its load status is checked in the other Kernels object. If it is loaded according to the other object, it is marked as loaded in this object and its managed state is set to unmanaged (since it contained in another object, no assumptions can be made as to whom and how it came about to be loaded.

The following code fragment demonstrates how to ensure only one Kernels object retains complete control of the merged set of kernels:

Kernels master, other;
// ...
// Both objects are assumed to contain kenels and some state.
master.Merge(other);
other.UnManage();
master.Manage();
master.UpdateLoadStatus();

The UpdateLoadStatus() ensures the state of the managed kernel list in master is completely up to date.

Parameters
otherOther Kenels object containing a separate list of NAIF kernels that will be merged with the contents of this object.
Returns
int Number of kernels added to this object. It does not include the count of kernels that are common to both and may have had its status modified.

Definition at line 616 of file Kernels.cpp.

◆ Missing()

int Isis::Kernels::Missing ( ) const

Return count of missing kernel files.

Returns
int Number of files that do not exist

Definition at line 137 of file Kernels.cpp.

◆ operator=()

Kernels & Isis::Kernels::operator= ( const Kernels kernels)

Copy constructor for existing Kernels objecr.

This copy constructor ensures the kernel list copied from an existing object is set to proper conditions as to minimize interference of both object that existence.

Any current kernels that in this object are removed without regard for ther current state. The list of kernels in the source object are copied and their state is analyzed. Any opened kernels are set to unmanaged state.

Author
kbecker (3/26/2011)
Parameters
kernelsSource list from which the list is copied
Returns
Kernels& Returned Kernel instance

Definition at line 93 of file Kernels.cpp.

◆ resolveType()

QString Isis::Kernels::resolveType ( const QString &  kfile) const
private

Determines type of NAIF/ISIS kernel we're dealing with.

This method will open the file and look at the first 8 characters. Valid NAIF binary and text kernels typically have its type defined in the first 8 characters. The expected format of these characters is "DAF/CK". This method retrieves this string, trims off formatting characters and spaces and returns the string after the "/" character. This value is returned as the kernel type.

It also checks for ISIS DEMs and a special case of ISIS IAKs, which does not follow the NAIF convention. ISIS IAKs don't typically contain the NAIF format identifier but do contain the ".ti" file extention.

UNKNOWN and DAF types are further checked by the filename. This is a last resort to properly tag kernel types that are ambiguous. DAFs are common for some SPKs. UNKNOWNs are common for many kernels that do not follow the NAIF standard first 8 character identifier model.

Parameters
kfileName of potential NAIF kernel to determine type for
Returns
QString Value of the identifier found. If undetermined, "UNKNOWN" is returned.

Definition at line 1125 of file Kernels.cpp.

References Isis::FileName::expanded(), Isis::IString::ToQt(), and Isis::IString::Trim().

◆ resolveTypeByExt()

QString Isis::Kernels::resolveTypeByExt ( const QString &  kfile,
const QString &  iktype = "UNKNOWN" 
) const
private

Check kernel type by file extension and special ISIS kernels.

This method is a fallback attempt to determine the type of an expected NAIF kernel. This method assumes the proper way (inspecting first 8 characters of the kernel file) did not succeed in making this determination.

There are some times that are expected to fail this test. ISIS DEMs are cube files and will not be determined using the NAIF 8 character approach. As such, all files that end in .cub are assumed to be DEMs and are tagged as such.

There are also some special ISIS IK addendum files that exist in the ISIS system. These files are used to augment an instruments' IK kernel and potentially override some of the original IK contents. This file type is determined by checking for a ".ti" extension and then further checking the base filename for the substring "Addendum". This is the only way to ensure it is an ISIS IAK file. It must pass both tests or it is simply tagged as an IK (due to the .ti extension).

The remainder of the tests are strictly testing the file extension. Here is how the associations are made to the files based upon their file extensions:

.cub = DEM - ISIS cubes are DEMs .ti = IK - unless "Addendum" is in basename, then it is an IAK .tf = FK - frames kernel .tsc = SCLK - spacecraft clock kernel .tsl = LSK - leap seconds kernel .tpc = PCK - planetary ephemeris kernel .bc = CK - C-kernel .bsp = SPK - spacecraft position kernel .bes = EK - event kernels .bds = DSK - NAIF DSK shape model kernel .meta = META - NAIF meta kernels file

If none of these file extensions or condition are found, then the value of the parameter iktype is returned as the default type.

Parameters
kfileFile to determine type for
iktypeDefault type to be used in none are determined from this methiod
Returns
QString Type of kernel found from file extensions

Definition at line 1198 of file Kernels.cpp.

References Isis::FileName::baseName(), and Isis::FileName::extension().

◆ size()

int Isis::Kernels::size ( ) const
inline

Returns the number of kernels found and/or loaded.

Definition at line 125 of file Kernels.h.

◆ UnLoad() [1/3]

int Isis::Kernels::UnLoad ( const QString &  ktypes)

Unloads all kernels of a specific type.

This method will parse a string containing acronyms of NAIF kernels types and close only those found with the associated type. Types in the context of this class are loosely managed. They are typically types returned by the NAIF utilities, kinfo_c and kdata_c.

Only those files that match will be unloaded. There load states will be altered to reflect its load status.

Only files that are tagged as manageable but this object are closed. Unmanaged kernels are essentially ignored.

Parameters
ktypesComma delimited string specifying the type to unload. This string is of the form "LSK,FK,SPK".
Returns
int Number of kernels unloaded

Definition at line 470 of file Kernels.cpp.

◆ UnLoad() [2/3]

int Isis::Kernels::UnLoad ( )

Unloads all kernels from the NAIF pool.

This method will unload all kernels from the kernel pool. It will unload them one at a time, which is known to be inefficient. You could consider using the InitializeNaifKernelPool() method for a more thorough and efficient cleansing.

Returns
int Number of kernels unloaded

Definition at line 442 of file Kernels.cpp.

Referenced by ~Kernels().

◆ UnLoad() [3/3]

bool Isis::Kernels::UnLoad ( KernelFile kfile)
private

Unloads a kernel from the NAIF kernel pool.

This method will unload a NAIF kernel from the kernel pool. If the internal load state does not indicate it is loaded, there will be no activity performed.

The file must also be tagged as manageable by this object. Certain conditions will affect the manageability of a NAIF kernel in this object. See the class documentation for details. In the situation of the file being tagged as unmanageable, the load state never changes. Use UpdateLoadStatus() to determine its true load state.

There is good chance that a NAIF kernel may no longer be loaded in the pool. This is particularly a real possibility as a side effect of this class. Errors are, therefore, ignored when encountered attempting to unload a kernel file. The state is then set to a unloaded condition.

Parameters
kfile
Returns
bool

Definition at line 831 of file Kernels.cpp.

◆ UnManage()

void Isis::Kernels::UnManage ( )

Set each kernels' management state to unmanaged.

This method changes the management state to unmanaged, thus restricting the ability of this method to unload loaded kernels.

When a kernel is marked as unmanaged, it will persist in its loaded state even after the destruction of this object (there is really no way to track how kernels get loaded reliably).

Definition at line 305 of file Kernels.cpp.

◆ UpdateLoadStatus()

int Isis::Kernels::UpdateLoadStatus ( )

Determine the load status of all kernels known to this object.

This method will reevaluate the load status of each NAIF kernel contained within this object. This method can be useful when there are more than one of these Kernels objects instantiated.

It will check to determine if each NAIF kernel is loaded using the NAIF kinfo_c utility. It will change loaded status to unloaded and unloaded status to loaded from results of the query. It does not consider the managed state of any kernel.

One can always choose to use the Load() and UnLoad() utilities for explicit handling of the kernel (type) states.

Returns
int Number of kernels whose states where changed/affected by this method

Definition at line 508 of file Kernels.cpp.

◆ UpdateManagedStatus()

int Isis::Kernels::UpdateManagedStatus ( )
private

Update the managed state of the kernel file list.

This method changes the managed state of individual files that are opened. If a file is determined to be open it sets the managed state such that this object will not manage it. In other words, it ensures it will not close the file when asked.

This method is intended to be used when copying the contents of another Kernels object and it will not allow closing of existing kernel files that are found to be open. It is useful to call the UpdateLoadStatus() method first to determine load states of files.

And files that it finds to be unloaded, it will set it manageable.

Author
kbecker (3/26/2011)
Returns
int

Definition at line 556 of file Kernels.cpp.


The documentation for this class was generated from the following files: