]> git.tdb.fi Git - builder.git/blobdiff - source/toolchain.cpp
Big rewrite for a more tool-centric approach
[builder.git] / source / toolchain.cpp
diff --git a/source/toolchain.cpp b/source/toolchain.cpp
new file mode 100644 (file)
index 0000000..6c7dae1
--- /dev/null
@@ -0,0 +1,31 @@
+#include <msp/core/maputils.h>
+#include "tool.h"
+#include "toolchain.h"
+
+using namespace std;
+using namespace Msp;
+
+Toolchain::~Toolchain()
+{
+       for(ToolMap::iterator i=tools.begin(); i!=tools.end(); ++i)
+               delete i->second;
+}
+
+void Toolchain::add_tool(Tool *tool)
+{
+       insert_unique(tools, tool->get_tag(), tool);
+}
+
+const Tool &Toolchain::get_tool(const string &tag) const
+{
+       return *get_item(tools, tag);
+}
+
+const Tool *Toolchain::get_tool_for_suffix(const string &suffix) const
+{
+       for(ToolMap::const_iterator i=tools.begin(); i!=tools.end(); ++i)
+               if(i->second->accepts_suffix(suffix))
+                       return i->second;
+
+       return 0;
+}