2024-04-13 11:52:42 +02:00
|
|
|
/*
|
2024-04-10 16:53:18 +02:00
|
|
|
* 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
|
|
|
|
|
2024-08-16 21:35:12 +02:00
|
|
|
#include "BaseFileResource.h"
|
2024-04-10 16:53:18 +02:00
|
|
|
#include "TaskItem.h"
|
|
|
|
#include "TodoMd.h"
|
2024-08-16 21:35:12 +02:00
|
|
|
#include "mirai-core/BaseResource.h"
|
2024-04-10 16:53:18 +02:00
|
|
|
#include <algorithm>
|
2024-04-14 14:11:41 +02:00
|
|
|
#include <functional>
|
2024-08-16 21:35:12 +02:00
|
|
|
#include <map>
|
2024-04-10 16:53:18 +02:00
|
|
|
#include <memory>
|
2024-04-14 14:11:41 +02:00
|
|
|
#include <optional>
|
|
|
|
#include <string>
|
2024-04-10 16:53:18 +02:00
|
|
|
|
2024-04-13 11:52:42 +02:00
|
|
|
namespace mirai
|
|
|
|
{
|
|
|
|
|
|
|
|
class Mirai
|
|
|
|
{
|
|
|
|
|
|
|
|
public:
|
2024-05-09 14:39:10 +02:00
|
|
|
void loadResource(std::unique_ptr<BaseResource> &&resource);
|
|
|
|
void unloadAllResources();
|
2024-04-13 11:52:42 +02:00
|
|
|
void save();
|
|
|
|
void removeTask(const TaskItem *taskItem);
|
2024-05-09 14:39:10 +02:00
|
|
|
std::optional<std::reference_wrapper<BaseResource>> getResourceByName(const std::string &name);
|
2024-04-13 11:52:42 +02:00
|
|
|
|
2024-05-09 14:39:10 +02:00
|
|
|
std::vector<std::unique_ptr<BaseResource>> &getResources();
|
2024-04-13 11:52:42 +02:00
|
|
|
const std::vector<std::string> &getTags();
|
|
|
|
|
2024-04-15 09:37:28 +02:00
|
|
|
void reloadTags();
|
|
|
|
|
2024-08-16 21:35:12 +02:00
|
|
|
// new stuff
|
|
|
|
|
|
|
|
// Returns a non owning pointer to the requested resource or nullptr if not found.
|
|
|
|
BaseResource *getResourceById(int id)
|
|
|
|
{
|
|
|
|
if (id >= resources_.size()) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
return resources_.at(id).get();
|
|
|
|
}
|
|
|
|
|
2024-04-13 11:52:42 +02:00
|
|
|
private:
|
2024-08-16 21:35:12 +02:00
|
|
|
std::vector<std::unique_ptr<BaseResource>> resources_;
|
|
|
|
std::vector<std::string> tags_;
|
2024-04-13 11:52:42 +02:00
|
|
|
};
|
|
|
|
} // namespace mirai
|
2024-04-10 16:53:18 +02:00
|
|
|
#endif
|