Skip to content

Commit

Permalink
chore: cache
Browse files Browse the repository at this point in the history
  • Loading branch information
neko-para committed Mar 21, 2024
1 parent 0eee470 commit 359dfb2
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 0 deletions.
1 change: 1 addition & 0 deletions source/MaaFramework/API/MaaTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ struct MaaDebugContextAPI
public:
virtual ~MaaDebugContextAPI() = default;

virtual std::vector<std::string> get_task_list() const = 0;
virtual const MAA_DEBUG_NS::Task* get_task_debug_info(std::string_view task) const = 0;
};

Expand Down
15 changes: 15 additions & 0 deletions source/MaaFramework/Debug/DebugContext.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include "DebugContext.h"

MAA_DEBUG_NS_BEGIN

DebugContext::DebugContext(TaskNS::PipelineTask* task)
: task_(task)
{
}

std::vector<std::string> DebugContext::get_task_list() const
{
return task_->data_mgr_.get_task_list();
}

MAA_DEBUG_NS_END
22 changes: 22 additions & 0 deletions source/MaaFramework/Debug/DebugContext.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#pragma once

#include "API/MaaTypes.h"
#include "Conf/Conf.h"
#include "Instance/InstanceInternalAPI.hpp"
#include "Task/PipelineTask.h"

MAA_DEBUG_NS_BEGIN

class DebugContext : public MaaDebugContextAPI
{
public:
DebugContext(TaskNS::PipelineTask* task);

virtual std::vector<std::string> get_task_list() const override;
virtual const MAA_DEBUG_NS::Task* get_task_debug_info(std::string_view task) const override;

private:
TaskNS::PipelineTask* task_;
};

MAA_DEBUG_NS_END
8 changes: 8 additions & 0 deletions source/MaaFramework/Task/PipelineTask.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,19 @@
#include "Task/Recognizer.h"
#include "Task/TaskDataMgr.h"

MAA_DEBUG_NS_BEGIN

class DebugContext;

MAA_DEBUG_NS_END

MAA_TASK_NS_BEGIN

class PipelineTask : public MaaInstanceSink
{
public:
friend class DebugNS::DebugContext;

using TaskData = MAA_RES_NS::TaskData;

public:
Expand Down
18 changes: 18 additions & 0 deletions source/MaaFramework/Task/TaskDataMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#include "Resource/ResourceMgr.h"
#include "Utils/ImageIo.h"
#include "Utils/Logger.h"
#include <ranges>
#include <vector>

MAA_TASK_NS_BEGIN

Expand All @@ -12,6 +14,22 @@ TaskDataMgr::TaskDataMgr(InstanceInternalAPI* inst)
{
}

std::vector<std::string> TaskDataMgr::get_task_list()
{
if (!resource()) {
LogError << "Resource not binded";
return {};
}
auto& raw_data_mgr = resource()->pipeline_res();
auto raw_tasks = raw_data_mgr.get_task_list();
auto diff_tasks = diff_tasks_ | std::views::keys;

std::set<std::string> tasks(raw_tasks.begin(), raw_tasks.end());
tasks.insert(diff_tasks.begin(), diff_tasks.end());

return std::vector<std::string>(tasks.begin(), tasks.end());
}

const MAA_RES_NS::TaskData& TaskDataMgr::get_task_data(const std::string& task_name)
{
if (!resource()) {
Expand Down
1 change: 1 addition & 0 deletions source/MaaFramework/Task/TaskDataMgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class TaskDataMgr
public:
explicit TaskDataMgr(InstanceInternalAPI* inst);

std::vector<std::string> get_task_list();
const TaskData& get_task_data(const std::string& task_name);
bool set_param(const json::value& param);

Expand Down

0 comments on commit 359dfb2

Please sign in to comment.