forgot to add the new files
[laserbrain_demo] / src / exman.cc
diff --git a/src/exman.cc b/src/exman.cc
new file mode 100644 (file)
index 0000000..e0ededc
--- /dev/null
@@ -0,0 +1,42 @@
+#include "exman.h"
+#include "exhibit.h"
+#include "blob_exhibit.h"
+
+static Exhibit *create_exhibit(const char *type);
+
+ExhibitManager::ExhibitManager()
+{
+}
+
+ExhibitManager::~ExhibitManager()
+{
+       int num = (int)items.size();
+       for(int i=0; i<num; i++) {
+               delete items[i];
+       }
+       items.clear();
+}
+
+bool ExhibitManager::load(const MetaScene *mscn, const char *fname)
+{
+       struct ts_node *root = ts_load(fname);
+       if(!root || strcmp(root->name, "exhibits") != 0) {
+               ts_free_tree(root);
+               error_log("failed to load exhibits\n");
+               return false;
+       }
+
+       ts_free_tree(root);
+       return true;
+}
+
+
+static Exhibit *create_exhibit(const char *type)
+{
+       if(strcmp(type, "static") == 0) {
+               return new Exhibit;
+       } else if(strcmp(type, "blobs") == 0) {
+               return new BlobExhibit;
+       }
+       return 0;
+}