aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/history
diff options
context:
space:
mode:
Diffstat (limited to 'src/openvic-simulation/history')
-rw-r--r--src/openvic-simulation/history/Bookmark.cpp15
-rw-r--r--src/openvic-simulation/history/Bookmark.hpp14
-rw-r--r--src/openvic-simulation/history/Period.cpp8
-rw-r--r--src/openvic-simulation/history/Period.hpp7
4 files changed, 29 insertions, 15 deletions
diff --git a/src/openvic-simulation/history/Bookmark.cpp b/src/openvic-simulation/history/Bookmark.cpp
index ee7b494..d42bd69 100644
--- a/src/openvic-simulation/history/Bookmark.cpp
+++ b/src/openvic-simulation/history/Bookmark.cpp
@@ -11,10 +11,19 @@ using namespace OpenVic;
using namespace OpenVic::NodeTools;
Bookmark::Bookmark(
- size_t new_index, std::string_view new_name, std::string_view new_description, Date new_date, uint32_t new_initial_camera_x,
+ index_t new_index,
+ std::string_view new_name,
+ std::string_view new_description,
+ Date new_date,
+ uint32_t new_initial_camera_x,
uint32_t new_initial_camera_y
-) : HasIdentifier { std::to_string(new_index) }, name { new_name }, description { new_description }, date { new_date },
- initial_camera_x { new_initial_camera_x }, initial_camera_y { new_initial_camera_y } {}
+) : HasIdentifier { std::to_string(new_index) },
+ HasIndex { new_index },
+ name { new_name },
+ description { new_description },
+ date { new_date },
+ initial_camera_x { new_initial_camera_x },
+ initial_camera_y { new_initial_camera_y } {}
bool BookmarkManager::add_bookmark(
std::string_view name, std::string_view description, Date date, uint32_t initial_camera_x, uint32_t initial_camera_y
diff --git a/src/openvic-simulation/history/Bookmark.hpp b/src/openvic-simulation/history/Bookmark.hpp
index 6f30586..d945d41 100644
--- a/src/openvic-simulation/history/Bookmark.hpp
+++ b/src/openvic-simulation/history/Bookmark.hpp
@@ -9,19 +9,23 @@
namespace OpenVic {
struct BookmarkManager;
- struct Bookmark : HasIdentifier {
+ struct Bookmark : HasIdentifier, HasIndex<> {
friend struct BookmarkManager;
private:
- const std::string PROPERTY(name);
- const std::string PROPERTY(description);
+ std::string PROPERTY(name);
+ std::string PROPERTY(description);
const Date PROPERTY(date);
const uint32_t PROPERTY(initial_camera_x);
const uint32_t PROPERTY(initial_camera_y);
Bookmark(
- size_t new_index, std::string_view new_name, std::string_view new_description, Date new_date,
- uint32_t new_initial_camera_x, uint32_t new_initial_camera_y
+ index_t new_index,
+ std::string_view new_name,
+ std::string_view new_description,
+ Date new_date,
+ uint32_t new_initial_camera_x,
+ uint32_t new_initial_camera_y
);
public:
diff --git a/src/openvic-simulation/history/Period.cpp b/src/openvic-simulation/history/Period.cpp
index 2c6589c..b5a9c82 100644
--- a/src/openvic-simulation/history/Period.cpp
+++ b/src/openvic-simulation/history/Period.cpp
@@ -5,15 +5,15 @@
using namespace OpenVic;
Period::Period(
- const Date new_start_date,
- const std::optional<Date> new_end_date
+ Date new_start_date,
+ std::optional<Date> new_end_date
) : start_date { new_start_date }, end_date { new_end_date } {}
-bool Period::is_date_in_period(const Date date) const {
+bool Period::is_date_in_period(Date date) const {
return start_date <= date && (!end_date.has_value() || end_date.value() >= date);
}
-bool Period::try_set_end(const Date date) {
+bool Period::try_set_end(Date date) {
if (end_date.has_value()) {
Logger::error("Period already has end date ", end_date.value());
return false;
diff --git a/src/openvic-simulation/history/Period.hpp b/src/openvic-simulation/history/Period.hpp
index d8b5ade..f59b16d 100644
--- a/src/openvic-simulation/history/Period.hpp
+++ b/src/openvic-simulation/history/Period.hpp
@@ -11,8 +11,9 @@ namespace OpenVic {
std::optional<Date> end_date;
public:
- Period(const Date new_start_date, const std::optional<Date> new_end_date);
- bool is_date_in_period(const Date date) const;
- bool try_set_end(const Date date);
+ Period(Date new_start_date, std::optional<Date> new_end_date);
+
+ bool is_date_in_period(Date date) const;
+ bool try_set_end(Date date);
};
}