Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/info.h')
-rw-r--r--src/core/info.h108
1 files changed, 108 insertions, 0 deletions
diff --git a/src/core/info.h b/src/core/info.h
new file mode 100644
index 0000000..cc480bf
--- /dev/null
+++ b/src/core/info.h
@@ -0,0 +1,108 @@
+/*
+ core/info.h
+ This file is part of the Osirion project and is distributed under
+ the terms of the GNU General Public License version 2
+*/
+
+#ifndef __INCLUDED_CORE_INFO_H__
+#define __INCLUDED_CORE_INFO_H__
+
+#include <iostream>
+#include <string>
+#include <map>
+#include <deque>
+
+#include "model/model.h"
+
+namespace core
+{
+
+/**
+ * an information record
+ */
+class Info
+{
+public:
+ /// create a new labeled information record
+ Info(const std::string & label);
+ /// delete the information record
+ ~Info();
+
+ typedef std::deque<std::string> Text;
+
+ inline const std::string & label() const { return info_label; }
+
+ inline const std::string & name() const { return info_name; }
+
+ inline const std::string & modelname() const { return info_modelname; }
+
+ inline const unsigned long &timestamp() const { return info_timestamp; }
+
+ inline Text & text() { return info_text; }
+
+ void set_name(const std::string & name);
+
+ void set_name(const char *name);
+
+ void set_modelname(const std::string & modelname);
+
+ void set_modelname(const char *modelname);
+
+ /// set the timestamp
+ void set_timestamp(const unsigned long timestamp);
+
+ /// clear the timestamp
+ void clear_timestamp();
+
+ /// add a line of info text
+ void add_text(const char *text);
+
+ /// add a line of info text
+ void add_text(const std::string & text);
+
+ /// clear the info text
+ void clear_text();
+
+ /// print info to sys::con_out
+ void print() const;
+
+ /// serialize a server-to-client update on a stream
+ void serialize_server_update(std::ostream & os) const;
+
+ /// receive a server-to-client update from a stream
+ void receive_server_update(std::istream &is);
+
+/* ---- static info registry --------------------------------------- */
+
+ typedef std::map<std::string, Info*> Registry;
+
+ /// add an item to the info regsitry
+ static void add(Info *info);
+
+ /// search the info registry for a labeled item
+ static Info *find(const char * label);
+
+ /// search the info registry for a labeled item
+ static Info *find(const std::string & label);
+
+ /// clear the info registry
+ static void clear();
+
+ /// list the info registry
+ static void list();
+
+private:
+ std::string info_label;
+ std::string info_name;
+ std::string info_modelname;
+ Text info_text;
+
+ long info_credits;
+ static Registry registry;
+
+ unsigned long info_timestamp;
+};
+
+}
+#endif // __INCLUDED_CORE_INFO_H__
+