Merge branch 'master' into thesis/2018/exoplanets

This commit is contained in:
Emma Broman
2020-09-11 13:43:01 +02:00
318 changed files with 3222 additions and 2604 deletions
+5 -1
View File
@@ -26,13 +26,17 @@
#define __OPENSPACE_CORE___MEMORYMANAGER___H__
#include <ghoul/misc/memorypool.h>
#include <memory_resource>
namespace openspace {
class MemoryManager {
public:
ghoul::MemoryPool<8 * 1024 * 1024, false> PersistentMemory;
ghoul::MemoryPool<10 * 1024, false> TemporaryMemory;
// This should be replaced with a std::pmr::memory_resource wrapper around our own
// Memory pool so that we can get a high-water mark out of it
ghoul::MemoryPool<100 * 4096, false> TemporaryMemory;
};
} // namespace openspace
+3 -2
View File
@@ -29,6 +29,7 @@
#include <chrono>
#include <mutex>
#include <string_view>
#include <vector>
namespace openspace {
@@ -91,8 +92,8 @@ public:
* \param category The category of the log message
* \param message The actual log message that was transmitted
*/
void log(ghoul::logging::LogLevel level, const std::string& category,
const std::string& message) override;
void log(ghoul::logging::LogLevel level, std::string_view category,
std::string_view message) override;
/**
* This method removes all the stored LogEntry%s that have expired, calculated by
+35 -3
View File
@@ -25,7 +25,9 @@
#ifndef __OPENSPACE_CORE___SPICEMANAGER___H__
#define __OPENSPACE_CORE___SPICEMANAGER___H__
#include <ghoul/fmt.h>
#include <ghoul/glm.h>
#include <ghoul/misc/assert.h>
#include <ghoul/misc/boolean.h>
#include <ghoul/misc/exception.h>
#include <array>
@@ -33,11 +35,15 @@
#include <string>
#include <vector>
#include <set>
#include "SpiceUsr.h"
#include "SpiceZpr.h"
namespace openspace {
namespace scripting { struct LuaLibrary; }
void throwSpiceError(const std::string& errorMessage);
class SpiceManager {
public:
BooleanType(UseException);
@@ -462,6 +468,7 @@ public:
* \sa http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/str2et_c.html
*/
double ephemerisTimeFromDate(const std::string& timeString) const;
double ephemerisTimeFromDate(const char* timeString) const;
/**
* Converts the passed \p ephemerisTime into a human-readable date string with a
@@ -469,15 +476,40 @@ public:
*
* \param ephemerisTime The ephemeris time, that is the number of TDB seconds past the
* J2000 epoch
* \param formatString The format string describing the output format
* \param format The format string describing the output format
* \return The destination for the converted date.
*
* \pre \p formatString must not be empty
* \pre \p format must not be empty
*
* \sa http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/timout_c.html
*/
template <int N = 31>
std::string dateFromEphemerisTime(double ephemerisTime,
const std::string& formatString = "YYYY MON DDTHR:MN:SC.### ::RND") const;
const char (&format)[N] = "YYYY MON DDTHR:MN:SC.### ::RND") const
{
static_assert(N != 0, "Format must not be empty");
std::string res;
res.resize(N);
dateFromEphemerisTime(ephemerisTime, res.data(), N, format);
return res;
}
template <int N>
void dateFromEphemerisTime(double ephemerisTime, char* outBuf, int bufferSize,
const char (&format)[N] = "YYYY MON DDTHR:MN:SC.### ::RND") const
{
static_assert(N != 0, "Format must not be empty");
ghoul_assert(N >= bufferSize - 1, "Buffer size too small");
timout_c(ephemerisTime, format, bufferSize, outBuf);
if (failed_c()) {
throwSpiceError(fmt::format(
"Error converting ephemeris time '{}' to date with format '{}'",
ephemerisTime, format
));
}
}
/**
* Returns the \p position of a \p target body relative to an \p observer in a
+15 -6
View File
@@ -64,8 +64,10 @@ public:
* \pre \p timeString must not be empty
*/
static double convertTime(const std::string& time);
static double convertTime(const char* time);
explicit Time(double secondsJ2000 = -1);
explicit Time(const std::string& time);
Time(const Time& other) = default;
/**
@@ -98,7 +100,8 @@ public:
* (http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/str2et_c.html)
* \param time The time to be set as a date string
*/
void setTime(std::string time);
void setTime(const std::string& time);
void setTime(const char* time);
/**
* Returns the current time as the number of seconds past the J2000 epoch. If the
@@ -112,13 +115,19 @@ public:
* thus also compliant with the Spice library.
* \return The current time as a formatted date string
*/
std::string UTC() const;
std::string_view UTC() const;
/**
* Returns the current time as a ISO 8601 formatted, i.e YYYY-MM-DDThh:mm:ssZ
* \return The current time as a ISO 8601 formatted string
*/
std::string ISO8601() const;
* Returns the current time as a ISO 8601 formatted, i.e YYYY-MM-DDThh:mm:ssZ
* \return The current time as a ISO 8601 formatted string
*/
std::string_view ISO8601() const;
/**
* Creates the current time as a ISO 8601 formatted, i.e YYYY-MM-DDThh:mm:ssZ into the
* provided Buffer. The buffer needs to have space for 25 characters.
*/
void ISO8601(char* buffer) const;
/**
* Advances the simulation time using the deltaTime() and the <code>tickTime</code>.