mirai/lib/mirai-core/BaseResource.h

74 lines
1.4 KiB
C
Raw Normal View History

/*
* Mirai. Copyright (C) 2024 Vyn
* This file is licensed under version 3 of the GNU General Public License (GPL-3.0-only)
* The license can be found in the LICENSE file or at https://www.gnu.org/licenses/gpl-3.0.txt
*/
#ifndef MIRAI_BASE_RESOURCE_H
#define MIRAI_BASE_RESOURCE_H
2024-08-16 21:35:12 +02:00
#include "TaskItem.h"
#include "mirai-core/DateTime.h"
#include "mirai-core/Day.h"
#include "mirai-core/Event.h"
#include <memory>
2024-08-16 21:35:12 +02:00
#include <optional>
#include <string>
#include <vector>
namespace mirai
{
class BaseResource
{
2024-08-16 21:35:12 +02:00
public:
2024-08-16 21:35:12 +02:00
struct AddTaskData {
std::string text;
Tags tags;
};
BaseResource(std::string name) : name_(name) {};
BaseResource(BaseResource &) = delete;
BaseResource(BaseResource &&) = delete;
virtual ~BaseResource() = default;
virtual void save() = 0;
virtual void load() = 0;
void setName(std::string name)
{
2024-08-16 21:35:12 +02:00
this->name_ = name;
}
const std::string &getName() const
{
2024-08-16 21:35:12 +02:00
return name_;
}
2024-08-16 21:35:12 +02:00
void addDay(const DayData &dayData);
Day *day(const Date &date);
std::vector<std::unique_ptr<Day>> *days();
TaskItem *getTaskById(int taskId);
Event *getEventById(int eventId);
void deleteTask(const TaskItem &task);
void setDirty(bool shouldBeDirty);
bool isDirty() const;
2024-08-16 21:35:12 +02:00
int id() const
{
return id_;
}
private:
2024-08-16 21:35:12 +02:00
static int nextId_;
int id_ = nextId_++;
std::string name_;
std::vector<std::unique_ptr<Day>> days_;
bool isDirty_ = false;
};
2024-08-11 16:46:44 +02:00
} // namespace mirai
#endif