52 lines
1.1 KiB
C
52 lines
1.1 KiB
C
|
#ifndef OPENMANUS_TOOL_COLLECTION_H
|
|||
|
#define OPENMANUS_TOOL_COLLECTION_H
|
|||
|
|
|||
|
#include <string>
|
|||
|
#include <vector>
|
|||
|
#include <memory>
|
|||
|
#include <unordered_map>
|
|||
|
#include "tool_base.h"
|
|||
|
|
|||
|
namespace openmanus {
|
|||
|
|
|||
|
/**
|
|||
|
* @class ToolCollection
|
|||
|
* @brief 工具集合类,管理所有可用的工具
|
|||
|
*/
|
|||
|
class ToolCollection {
|
|||
|
public:
|
|||
|
ToolCollection();
|
|||
|
~ToolCollection() = default;
|
|||
|
|
|||
|
/**
|
|||
|
* @brief 添加工具到集合中
|
|||
|
* @param tool 要添加的工具
|
|||
|
*/
|
|||
|
void addTool(std::unique_ptr<ToolBase> tool);
|
|||
|
|
|||
|
/**
|
|||
|
* @brief 根据名称获取工具
|
|||
|
* @param name 工具名称
|
|||
|
* @return 工具指针,如果不存在则返回nullptr
|
|||
|
*/
|
|||
|
ToolBase* getTool(const std::string& name);
|
|||
|
|
|||
|
/**
|
|||
|
* @brief 获取所有工具的名称
|
|||
|
* @return 工具名称列表
|
|||
|
*/
|
|||
|
std::vector<std::string> getToolNames() const;
|
|||
|
|
|||
|
/**
|
|||
|
* @brief 获取工具数量
|
|||
|
* @return 工具数量
|
|||
|
*/
|
|||
|
size_t size() const { return tools_.size(); }
|
|||
|
|
|||
|
private:
|
|||
|
std::unordered_map<std::string, std::unique_ptr<ToolBase>> tools_;
|
|||
|
};
|
|||
|
|
|||
|
} // namespace openmanus
|
|||
|
|
|||
|
#endif // OPENMANUS_TOOL_COLLECTION_H
|