35 lines
757 B
C++
35 lines
757 B
C++
#include "include/tool_collection.h"
|
|
|
|
namespace openmanus {
|
|
|
|
ToolCollection::ToolCollection() {
|
|
// 初始化工具集合
|
|
}
|
|
|
|
void ToolCollection::addTool(std::unique_ptr<ToolBase> tool) {
|
|
if (tool) {
|
|
std::string name = tool->getName();
|
|
tools_[name] = std::move(tool);
|
|
}
|
|
}
|
|
|
|
ToolBase* ToolCollection::getTool(const std::string& name) {
|
|
auto it = tools_.find(name);
|
|
if (it != tools_.end()) {
|
|
return it->second.get();
|
|
}
|
|
return nullptr;
|
|
}
|
|
|
|
std::vector<std::string> ToolCollection::getToolNames() const {
|
|
std::vector<std::string> names;
|
|
names.reserve(tools_.size());
|
|
|
|
for (const auto& pair : tools_) {
|
|
names.push_back(pair.first);
|
|
}
|
|
|
|
return names;
|
|
}
|
|
|
|
} // namespace openmanus
|