Add Lua function to return a list of all loaded kernels

This commit is contained in:
Alexander Bock
2023-12-22 14:40:58 +01:00
parent e64d4d66f4
commit 952b263a8e
3 changed files with 26 additions and 1 deletions
+8
View File
@@ -232,6 +232,14 @@ public:
*/
void unloadKernel(KernelHandle kernelId);
/**
* Returns a list of all loaded kernels in the kernel pool that have been loaded
* through the SpiceManager. The kernels are reported in order of their loading.
*
* \return The list of all loaded kernels that have been loaded through this manager
*/
std::vector<std::string> loadedKernels() const;
/**
* Unloads a SPICE kernel identified by the \p filePath which was used in the
* loading call to #loadKernel. The unloading is done by calling the `unload_c`
+11 -1
View File
@@ -324,6 +324,15 @@ void SpiceManager::unloadKernel(std::string filePath) {
}
}
std::vector<std::string> SpiceManager::loadedKernels() const {
std::vector<std::string> res;
res.reserve(_loadedKernels.size());
for (const KernelInformation& info : _loadedKernels) {
res.push_back(info.path);
}
return res;
}
bool SpiceManager::hasSpkCoverage(const std::string& target, double et) const {
ghoul_assert(!target.empty(), "Empty target");
@@ -1530,9 +1539,10 @@ scripting::LuaLibrary SpiceManager::luaLibrary() {
{
codegen::lua::LoadKernel,
codegen::lua::UnloadKernel,
codegen::lua::Kernels,
codegen::lua::SpiceBodies,
codegen::lua::RotationMatrix,
codegen::lua::Position
codegen::lua::Position,
}
};
}
+7
View File
@@ -68,6 +68,13 @@ namespace {
}
}
/**
* Returns a list of all loaded kernels
*/
[[codegen::luawrap]] std::vector<std::string> kernels() {
return openspace::SpiceManager::ref().loadedKernels();
}
/**
* Returns a list of Spice Bodies loaded into the system. Returns SPICE built in frames if
* builtInFrames. Returns User loaded frames if !builtInFrames.