]> git.tdb.fi Git - libs/gl.git/blobdiff - source/technique.cpp
Use maputils functions
[libs/gl.git] / source / technique.cpp
index 49b487982993d259f3807c8b3820f9991cf85998..b809abdebb69fdcf4d1a015473285713d5c297f6 100644 (file)
@@ -1,13 +1,6 @@
-/* $Id$
-
-This file is part of libmspgl
-Copyright © 2008-2011  Mikko Rasa, Mikkosoft Productions
-Distributed under the LGPL
-*/
-
 #include <msp/core/refptr.h>
 #include <msp/datafile/collection.h>
-#include <msp/strings/formatter.h>
+#include <msp/strings/format.h>
 #include "material.h"
 #include "program.h"
 #include "programdata.h"
@@ -22,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
@@ -35,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);
 }
 
 
@@ -69,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);
 }