From: Mikko Rasa Date: Tue, 6 Sep 2011 20:37:38 +0000 (+0300) Subject: Use maputils functions X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=97e1aa9b5d2bacd3f1dddf2d1889f2714e36b766;p=libs%2Fgl.git Use maputils functions --- diff --git a/source/pipeline.cpp b/source/pipeline.cpp index de98b2d3..eca9a49a 100644 --- a/source/pipeline.cpp +++ b/source/pipeline.cpp @@ -1,7 +1,7 @@ +#include #include "blend.h" #include "camera.h" #include "effect.h" -#include "except.h" #include "framebuffer.h" #include "lighting.h" #include "pipeline.h" @@ -58,28 +58,19 @@ void Pipeline::set_camera(const Camera *c) PipelinePass &Pipeline::add_pass(const Tag &tag) { - if(passes.count(tag)) - throw KeyError("Pass already exists"); - - PipelinePass &pass = passes[tag]; + PipelinePass &pass = insert_unique(passes, tag, PipelinePass())->second; pass_order.push_back(tag); return pass; } PipelinePass &Pipeline::get_pass(const Tag &tag) { - PassMap::iterator i = passes.find(tag); - if(i==passes.end()) - throw KeyError("Unknown pass"); - return i->second; + return get_item(passes, tag); } const PipelinePass &Pipeline::get_pass(const Tag &tag) const { - PassMap::const_iterator i = passes.find(tag); - if(i==passes.end()) - throw KeyError("Unknown pass"); - return i->second; + return get_item(passes, tag); } void Pipeline::add_renderable(const Renderable &r) diff --git a/source/technique.cpp b/source/technique.cpp index 2a8928a0..b809abde 100644 --- a/source/technique.cpp +++ b/source/technique.cpp @@ -15,10 +15,7 @@ namespace GL { RenderPass &Technique::add_pass(const GL::Tag &tag) { - if(passes.count(tag)) - throw KeyError("Duplicate pass"); - - return passes[tag]; + return insert_unique(passes, tag, RenderPass())->second; } bool Technique::has_pass(const GL::Tag &tag) const @@ -28,10 +25,7 @@ bool Technique::has_pass(const GL::Tag &tag) const const RenderPass &Technique::get_pass(const GL::Tag &tag) const { - PassMap::const_iterator i = passes.find(tag); - if(i==passes.end()) - throw KeyError("Unknown pass"); - return i->second; + return get_item(passes, tag); } @@ -62,16 +56,13 @@ void Technique::Loader::inherit(const string &n) void Technique::Loader::pass(const string &n) { - Tag tag(n); - if(obj.passes.count(tag)) - throw KeyError("Duplicate pass name", n); - RenderPass p; if(coll) load_sub(p, get_collection()); else load_sub(p); - obj.passes.insert(PassMap::value_type(tag, p)); + + insert_unique(obj.passes, n, p); }