22 lines
677 B
C++
22 lines
677 B
C++
#pragma once
|
|
#include "tool.hpp"
|
|
#include <expected>
|
|
#include <optional>
|
|
#include <string>
|
|
#include <unordered_map>
|
|
#include <vector>
|
|
|
|
class ToolRegistry {
|
|
public:
|
|
std::expected<void, std::string> register_tool(Tool tool);
|
|
std::optional<const Tool*> find(const std::string& name) const;
|
|
std::vector<Tool> tools() const;
|
|
Content invoke(const std::string& name, const nlohmann::json& args) const;
|
|
std::expected<ToolRegistry, std::string> create_subregistry(std::vector<std::string> const& names) const;
|
|
std::vector<std::string> const& tool_names() const;
|
|
|
|
private:
|
|
std::vector<std::string> order_;
|
|
std::unordered_map<std::string, Tool> tools_;
|
|
};
|