quick backup:
[demo] / src / state_manager.h
diff --git a/src/state_manager.h b/src/state_manager.h
new file mode 100644 (file)
index 0000000..4894644
--- /dev/null
@@ -0,0 +1,48 @@
+#ifndef STATE_MANAGER_H_
+#define STATE_MANAGER_H_
+
+#include <gmath/gmath.h>
+#include <map>
+
+#include <string>
+#include <vector>
+
+struct State {
+       int num;
+       char *name;
+       float *data;
+};
+
+class StateManager {
+private:
+       std::map<std::string, int> statemap;
+       State *get_state(const char *name);
+
+public:
+       std::vector<State> states;
+
+       /*
+               adds a state returns an idx:
+               the num_floats indicates the number of floats that form
+               the state element.
+               For example:
+               a float value consists of 1 float => num_floats = 1,
+               a Vec2 consists of 2 floats, a Vec3 from 3, a Vec4 from 4
+
+               see also:
+               set_state(const char *name, const Mat4 &mat implementation)
+       */
+       int add_state_element(const char *name, int num_floats);
+
+       void set_state(const char *name, float value);
+       void set_state(const char *name, const Vec3 &vec);
+       void set_state(const char *name, const Vec4 &vec);
+       void set_state(const char *name, const Mat4 &mat);
+
+       const State *get_state(const char *name) const;
+       const State *get_state(int idx) const;
+};
+
+extern StateManager state_manager;
+
+#endif // STATE_MANAGER_H_
\ No newline at end of file