Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2014-12-25 15:58:24 +0000
committerStijn Buys <ingar@osirion.org>2014-12-25 15:58:24 +0000
commit8f393ff70e60172c632efc81694433568df2862b (patch)
treeac87596d59ccf27dff0896c97e410643d21185bf /src/core/info.h
parent8f28c82e2fb26b453a2cfe976e48f74d97d6388a (diff)
Added a core::Level type, added a level attribute to core::Entity and core::Info, updated core::Player to use the new type.
Diffstat (limited to 'src/core/info.h')
-rw-r--r--src/core/info.h121
1 files changed, 89 insertions, 32 deletions
diff --git a/src/core/info.h b/src/core/info.h
index 2859dac..5aca5b2 100644
--- a/src/core/info.h
+++ b/src/core/info.h
@@ -13,6 +13,7 @@
#include <deque>
#include "core/label.h"
+#include "core/level.h"
#include "model/model.h"
namespace core
@@ -25,7 +26,9 @@ namespace core
class InfoType : public Label
{
public:
- /// info registry type definition
+ /**
+ * @brief info type registry type definition
+ * */
typedef std::vector<InfoType*> Registry;
/**
@@ -36,19 +39,26 @@ public:
virtual ~InfoType();
- /* ---- static infoclass registry ---------------------------------- */
+ /* ---- static inf type registry ----------------------------------- */
- /// clear infotype registry
+ /**
+ * @brief clear info type registry
+ * */
static void clear();
- /// search the infotype registry for a label
+ /**
+ * @brief search the info type registry for a label
+ * */
static InfoType *find(const std::string & label);
- inline static const Registry &registry() {
+ inline static const Registry &registry()
+ {
return infotype_registry;
}
- /// list the infotypes
+ /**
+ * @brief list the info types
+ * */
static void list();
private:
@@ -64,42 +74,56 @@ private:
class Info : public Label
{
public:
- /// type definition for the text description
+ /**
+ * @brief type definition for the text description
+ * */
typedef std::deque<std::string> Text;
/**
- * @brief create a new server-side information card
+ * @brief server-side constructor
* This constructor assigns an id
*/
Info(const InfoType *type, const char *label = 0);
/**
- * @brief create a new client-side information card
+ * @brief client-side constructor
*/
Info(const unsigned int id);
- /// delete the information record
+ /**
+ * @brief default constructor
+ **/
virtual ~Info();
/* ---- inspectors ------------------------------------------------- */
- inline const unsigned int id() const {
+ inline const unsigned int id() const
+ {
return info_id;
}
- inline const InfoType* type() const {
+ inline const InfoType* type() const
+ {
return info_type;
}
- inline const std::string & modelname() const {
+ inline const std::string & modelname() const
+ {
return info_modelname;
}
- inline const long price() const {
+ inline const Level level() const
+ {
+ return info_level;
+ }
+
+ inline const long price() const
+ {
return info_price;
}
- inline const float volume() const {
+ inline const float volume() const
+ {
return info_volume;
}
@@ -110,14 +134,16 @@ public:
* If the info has been received from the server, the timestamp
* is set to 0
*/
- inline const unsigned long &timestamp() const {
+ inline const unsigned long &timestamp() const
+ {
return info_timestamp;
}
/**
- * @brief text description
+ * @brief info description text
*/
- inline const Text & text() const {
+ inline const Text & text() const
+ {
return info_text;
}
@@ -130,6 +156,11 @@ public:
void set_modelname(const char *modelname);
/**
+ * @brief set level
+ * */
+ void set_level(const Level level);
+
+ /**
* @brief associated price, in credits
*/
void set_price(const long price);
@@ -139,47 +170,74 @@ public:
*/
void set_volume(const float volume);
- /// set the timestamp
+ /**
+ * @brief set the timestamp
+ * */
void set_timestamp(const unsigned long timestamp);
- /// add a line of info text
+ /**
+ * @brief append a line of text to the info description
+ * add_line() adds a newline character
+ * */
void add_line(const std::string & text);
- /// add a line of info text
+ /**
+ * @brief append a line of text to the info description
+ * add_line() adds a newline character
+ * */
void add_line(const char *text);
- /// add info text without newline
+ /**
+ * @brief append text to the info description
+ * add_text() does not add a newline character
+ * */
void add_text(const std::string & text);
- /// add info text without newline
+ /**
+ * @brief append text to the info description
+ * add_text() does not add a newline character
+ * */
void add_text(const char *text);
-
- /// clear the info text
+ /**
+ * @brief clear the info description text
+ * */
void clear_text();
- /// print info to the system console
+ /**
+ * @brief print the content of the info record to the system console
+ * */
virtual void print() const;
- /// clear the timestamp
+ /**
+ * @brief clear the timestamp
+ * */
void clear_timestamp();
- /// set the info class type
+ /**
+ * @brief set the info type
+ * */
void set_type(const InfoType *type);
public:
/* ---- serializers ------------------------------------------------ */
- /// serialize a server-to-client update on a stream
+ /**
+ * @brief 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
+ /**
+ * @brief receive a server-to-client update from a stream
+ * */
void receive_server_update(std::istream &is);
private:
const InfoType* info_type;
unsigned int info_id;
+ Level info_level;
+
long info_price;
float info_volume;
unsigned long info_timestamp;
@@ -187,8 +245,7 @@ private:
Text info_text;
- /* ---- static info registry --------------------------------------- */
-
+ /* ---- static info registry --------------------------------------- */
public:
/**
* @brief info registry type definition