Commits

Matthew Turk  committed c4f2065

Beginning to add the field container class.

  • Participants
  • Parent commits 0678aac

Comments (0)

Files changed (2)

File src/enzo/ProblemType.C

 
 }
 
+void FieldContainer::add_field(std::string field_name, float default_value)
+{
+    if (this->default_values.count(field_name) != 0)
+        ENZO_VFAIL("Tried to reset default for %s", field_name.c_str())
+    this->default_values[field_name] = default_value;
+    return;
+}
+
+void FieldContainer::reset()
+{
+    for (std::map<std::string, float>::iterator it =
+            this->default_values.begin();
+         it != this->default_values.end();
+         it++)
+    {
+        this->field_values[it->first] = it->second;
+    }
+    return;
+}
+
+float& FieldContainer::operator[](std::string field_name)
+{
+    if (this->field_values.count(field_name) == 0)
+        ENZO_VFAIL("Asked for %s but it did not exist as a field.", field_name.c_str())
+    return this->field_values[field_name];
+}
+
 #endif

File src/enzo/ProblemType.h

 //! failsafe version to select the plug-in
 EnzoProblemType *select_problem_type( std::string problem_type_name );
 
+class FieldContainer
+{
+    public:
+        float &operator[](std::string);
+        void add_field(std::string, float default_value);
+        void reset();
+    private:
+        std::map<std::string, float> field_values;
+        std::map<std::string, float> default_values;
+};
+
+
 #endif
 #endif