Parcourir la source

View: add new methos for selector with one variable

Eric Ramat il y a 6 ans
Parent
commit
26347d181d
1 fichiers modifiés avec 15 ajouts et 3 suppressions
  1. 15 3
      src/artis-star/common/observer/View.hpp

+ 15 - 3
src/artis-star/common/observer/View.hpp

@@ -148,6 +148,19 @@ public:
         }
     }
 
+    const Values& get(const std::string& selector_name) const
+    {
+        SelectorValues::const_iterator it = _values.find(selector_name);
+
+        if (it != _values.end()) {
+            assert(it->second.size() == 1);
+
+            return it->second.begin()->second;
+        } else {
+            assert(false);
+        }
+    }
+
     void observe(double time, const common::Model < common::DoubleTime >* model,
                  const std::string& selector_name, unsigned int variable_index)
     {
@@ -210,7 +223,6 @@ public:
     void selector(const std::string& name, const Selector& chain)
     {
         _selectors[name] = chain;
-        _values[name] = VariableValues();
     }
 
     const SelectorValues& values() const
@@ -219,8 +231,8 @@ public:
 private:
     typedef std::map < std::string, Selector > Selectors;
 
-    Selectors                               _selectors;
-    SelectorValues                          _values;
+    Selectors                            _selectors;
+    SelectorValues                       _values;
     const artis::common::Model < Time >* _model;
 };