/* * 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_MIRAI_H #define MIRAI_MIRAI_H #include "TaskItem.h" #include "TasksFile.h" #include "TasksView.h" #include "TodoMd.h" #include #include namespace mirai { class Mirai { public: void loadFile(const std::string& path); void save(); void addTask(std::string text, std::string date); void removeTask(const TaskItem* taskItem); std::weak_ptr getTasks(); const std::vector& getTags(); private: // The `TasksFile`s are shared to the views, their lifetime can outlive // this (Mirai) object // because we can't control if the caller will keep the main object alive. std::shared_ptr> files = std::make_shared>(); // We keep a vector of shared_ptr because we need the ref counting mechanism to know // if we have to remove the view (not used) or tell the view to update() on // some changes. std::vector> views; std::vector tags; }; } #endif