diff mbox

[Branch,~glcompbench-dev/glcompbench/trunk] Rev 24: Add support for test options.

Message ID 20110622092719.30588.2993.launchpad@loganberry.canonical.com
State Accepted
Headers show

Commit Message

alexandros.frantzis@linaro.org June 22, 2011, 9:27 a.m. UTC
------------------------------------------------------------
revno: 24
committer: Alexandros Frantzis <alexandros.frantzis@linaro.org>
branch nick: trunk
timestamp: Wed 2011-06-22 12:12:20 +0300
message:
  Add support for test options.
modified:
  src/composite-test.cc
  src/composite-test.h


--
lp:glcompbench
https://code.launchpad.net/~glcompbench-dev/glcompbench/trunk

You are subscribed to branch lp:glcompbench.
To unsubscribe from this branch go to https://code.launchpad.net/~glcompbench-dev/glcompbench/trunk/+edit-subscription
diff mbox

Patch

=== modified file 'src/composite-test.cc'
--- src/composite-test.cc	2011-05-03 16:41:28 +0000
+++ src/composite-test.cc	2011-06-22 09:12:20 +0000
@@ -26,6 +26,7 @@ 
 #include "log.h"
 
 using std::string;
+using std::map;
 
 const string CompositeTest::model_view_matrix_name_("modelview");
 const string CompositeTest::projection_matrix_name_("projection");
@@ -219,3 +220,30 @@ 
 {
     program_.stop();
 }
+
+bool
+CompositeTest::set_option(const string &opt, const string &val)
+{ 
+    map<string, Option>::iterator iter = options_.find(opt);
+
+    if (iter == options_.end())
+        return false;
+
+    iter->second.value = val;
+
+    return true;
+}
+
+void
+CompositeTest::reset_options()
+{
+    for (map<string, Option>::iterator iter = options_.begin();
+         iter != options_.end();
+         iter++)
+    {
+        Option &opt = iter->second;
+
+        opt.value = opt.default_value;
+    }
+}
+

=== modified file 'src/composite-test.h'
--- src/composite-test.h	2011-05-03 16:41:28 +0000
+++ src/composite-test.h	2011-06-22 09:12:20 +0000
@@ -26,6 +26,7 @@ 
 
 #include <string>
 #include <list>
+#include <map>
 #include "stack.h"
 #include "program.h"
 #include "composite-window.h"
@@ -44,6 +45,21 @@ 
     virtual void cleanup();
     virtual void reshape(int width, int height);
     const std::string& name() const { return name_; }
+
+    struct Option {
+        Option(const std::string &name, const std::string &val, const std::string &desc) :
+            name(name), value(val), default_value(val), description(desc) {}
+        Option() {}
+        std::string name;
+        std::string value;
+        std::string default_value;
+        std::string description;
+    };
+
+    bool set_option(const std::string &opt, const std::string &val);
+    void reset_options();
+    const std::map<std::string, Option> &options() { return options_; }
+
 protected:
     CompositeTest();
     //
@@ -55,6 +71,7 @@ 
     //
     int num_visible_windows(std::list<CompositeWindow *> &window_list);
     std::string name_;
+    std::map<std::string, Option> options_;
     Program program_;
     std::string vertex_shader_;
     std::string fragment_shader_;