{
for(ToolMap::iterator i=tools.begin(); i!=tools.end(); ++i)
delete i->second;
+ for(ToolchainList::iterator i=chains.begin(); i!=chains.end(); ++i)
+ delete *i;
}
void Toolchain::add_tool(Tool *tool)
insert_unique(tools, tool->get_tag(), tool);
}
+void Toolchain::add_toolchain(Toolchain *chain)
+{
+ chains.push_back(chain);
+}
+
+bool Toolchain::has_tool(const string &tag) const
+{
+ if(tools.count(tag))
+ return true;
+ for(ToolchainList::const_iterator i=chains.begin(); i!=chains.end(); ++i)
+ if((*i)->has_tool(tag))
+ return true;
+ return false;
+}
+
Tool &Toolchain::get_tool(const string &tag) const
{
+ if(!tools.count(tag))
+ {
+ for(ToolchainList::const_iterator i=chains.begin(); i!=chains.end(); ++i)
+ if((*i)->has_tool(tag))
+ return (*i)->get_tool(tag);
+ }
+
return *get_item(tools, tag);
}
if(i->second->accepts_suffix(suffix, aux))
return i->second;
+ for(ToolchainList::const_iterator i=chains.begin(); i!=chains.end(); ++i)
+ if(Tool *tool = (*i)->get_tool_for_suffix(suffix, aux))
+ return tool;
+
return 0;
}
#ifndef TOOLCHAIN_H_
#define TOOLCHAIN_H_
+#include <list>
#include <map>
#include <string>
{
private:
typedef std::map<std::string, Tool *> ToolMap;
+ typedef std::list<Toolchain *> ToolchainList;
ToolMap tools;
+ ToolchainList chains;
public:
~Toolchain();
void add_tool(Tool *);
+ void add_toolchain(Toolchain *);
+ bool has_tool(const std::string &) const;
Tool &get_tool(const std::string &) const;
Tool *get_tool_for_suffix(const std::string &, bool = false) const;
};