mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-04 02:29:49 -06:00
Make SpiceManager derive from Singleton
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -42,33 +42,24 @@ namespace openspace {
|
||||
|
||||
SpiceManager* SpiceManager::_manager = nullptr;
|
||||
|
||||
void SpiceManager::initialize() {
|
||||
assert(_manager == nullptr);
|
||||
_manager = new SpiceManager;
|
||||
_manager->_lastAssignedKernel = 0;
|
||||
|
||||
// Set the SPICE library to not exit the program if an error occurs
|
||||
erract_c("SET", 0, const_cast<char*>("REPORT"));
|
||||
// But we do not want SPICE to print the errors, we will fetch them ourselves
|
||||
errprt_c("SET", 0, const_cast<char*>("NONE"));
|
||||
SpiceManager::SpiceManager()
|
||||
: _lastAssignedKernel(0)
|
||||
{
|
||||
// Set the SPICE library to not exit the program if an error occurs
|
||||
erract_c("SET", 0, const_cast<char*>("REPORT"));
|
||||
// But we do not want SPICE to print the errors, we will fetch them ourselves
|
||||
errprt_c("SET", 0, const_cast<char*>("NONE"));
|
||||
}
|
||||
|
||||
void SpiceManager::deinitialize() {
|
||||
for (const KernelInformation& i : _manager->_loadedKernels)
|
||||
unload_c(i.path.c_str());
|
||||
SpiceManager::~SpiceManager() {
|
||||
for (const KernelInformation& i : _manager->_loadedKernels)
|
||||
unload_c(i.path.c_str());
|
||||
|
||||
delete _manager;
|
||||
_manager = nullptr;
|
||||
|
||||
// Set values back to default
|
||||
erract_c("SET", 0, const_cast<char*>("DEFAULT"));
|
||||
errprt_c("SET", 0, const_cast<char*>("DEFAULT"));
|
||||
// Set values back to default
|
||||
erract_c("SET", 0, const_cast<char*>("DEFAULT"));
|
||||
errprt_c("SET", 0, const_cast<char*>("DEFAULT"));
|
||||
}
|
||||
|
||||
SpiceManager& SpiceManager::ref() {
|
||||
assert(_manager != nullptr);
|
||||
return *_manager;
|
||||
}
|
||||
|
||||
SpiceManager::KernelIdentifier SpiceManager::loadKernel(const std::string& filePath) {
|
||||
if (filePath.empty()) {
|
||||
@@ -1068,4 +1059,4 @@ bool SpiceManager::getPlanetEllipsoid(std::string planetName, float &a, float &b
|
||||
return !hasError;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user