Commit cb6d311f authored by Simon Spannagel's avatar Simon Spannagel
Browse files

Clipboard: add dedicated Event object storage

parent 5e0ae4f4
......@@ -31,6 +31,26 @@ double Clipboard::get_persistent(std::string name) {
}
}
bool Clipboard::event_defined() {
return (m_event != nullptr);
}
void Clipboard::put_event(std::shared_ptr<Event> event) {
// Already defined:
if(m_event) {
throw InvalidDataError("event already defined");
} else {
m_event = event;
}
}
std::shared_ptr<Event> Clipboard::get_event() {
if(!m_event) {
throw MissingDataError("event");
}
return m_event;
}
bool Clipboard::has_persistent(std::string name) {
return m_persistent_data.find(name) != m_persistent_data.end();
}
......
......@@ -15,6 +15,7 @@
#include <unordered_map>
#include "core/utils/log.h"
#include "objects/Event.hpp"
#include "objects/Object.hpp"
namespace corryvreckan {
......@@ -64,6 +65,26 @@ namespace corryvreckan {
*/
Objects* get(std::string name, std::string type = "");
/**
* @brief Check whether an event has been defined
* @return true if an event has been defined, false otherwise
*/
bool event_defined();
/**
* @brief Store the event object
* @param event The event object to be stored
* @thorws InvalidDataError in case an event exist already
*/
void put_event(std::shared_ptr<Event> event);
/**
* @brief Retrieve the event object
* @returnShared pointer to the event
* @throws MissingDataError in case no event is available.
*/
std::shared_ptr<Event> get_event();
/**
* @brief Store or update variable on the persistent clipboard storage
* @param name Name of the variable
......@@ -105,6 +126,9 @@ namespace corryvreckan {
// Persistent clipboard storage
std::unordered_map<std::string, double> m_persistent_data;
// Store the current time slice:
std::shared_ptr<Event> m_event{};
};
} // namespace corryvreckan
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment