mirror of
https://codeberg.org/vyn/mirai.git
synced 2025-07-01 17:03:19 +00:00
73 lines
1.4 KiB
C++
73 lines
1.4 KiB
C++
/*
|
|
* 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
|
|
|
|
#include "TaskItem.h"
|
|
#include "mirai-core/DateTime.h"
|
|
#include "mirai-core/Day.h"
|
|
#include "mirai-core/Event.h"
|
|
#include <memory>
|
|
#include <optional>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
namespace mirai
|
|
{
|
|
|
|
class BaseResource
|
|
{
|
|
|
|
public:
|
|
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)
|
|
{
|
|
this->name_ = name;
|
|
}
|
|
|
|
const std::string &getName() const
|
|
{
|
|
return name_;
|
|
}
|
|
|
|
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;
|
|
|
|
int id() const
|
|
{
|
|
return id_;
|
|
}
|
|
|
|
private:
|
|
static int nextId_;
|
|
int id_ = nextId_++;
|
|
std::string name_;
|
|
std::vector<std::unique_ptr<Day>> days_;
|
|
bool isDirty_ = false;
|
|
};
|
|
|
|
} // namespace mirai
|
|
#endif
|