/*
 * 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
 */

#pragma once

#include "DateTime.h"
#include "Day.h"
#include "Event.h"
#include "TaskItem.h"
#include <memory>
#include <optional>
#include <string>
#include <vector>

namespace mirai
{

class BaseSource
{

  public:
	struct AddTaskData {
		std::string text;
		Tags tags;
	};

	BaseSource(std::string name) : name_(name) {};
	BaseSource(BaseSource &) = delete;
	BaseSource(BaseSource &&) = delete;

	virtual ~BaseSource() = default;
	virtual void save() = 0;
	virtual void load() = 0;

	void setName(std::string name);
	const std::string &getName() const;

	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;

  private:
	static int nextId_;
	int id_ = nextId_++;
	std::string name_;
	std::vector<std::unique_ptr<Day>> days_;
	bool isDirty_ = false;
};

} // namespace mirai
