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/cvar.h')
-rw-r--r--src/core/cvar.h96
1 files changed, 52 insertions, 44 deletions
diff --git a/src/core/cvar.h b/src/core/cvar.h
index 8861f2a..4c3d942 100644
--- a/src/core/cvar.h
+++ b/src/core/cvar.h
@@ -13,12 +13,16 @@
namespace core
{
-/// a variable encapsulation class
+/**
+ * @brief a client variable encapsulation class
+ * values f client variables can be set through the command console interface
+ */
class Cvar
{
public:
- /// Cvar flags
/**
+ * @brief Cvar flags
+ *
* Archive a cvar with this flag will be saved to the configuration file
* ReadOnly the value of cvar with this flag can not be altered from the commandline
* Game a cvar with this flag is only valid when a game is loaded
@@ -27,86 +31,90 @@ public:
enum Flags {Archive=1, ReadOnly=2, Game=4, Info=8};
/// create a new variable
- Cvar(const char *name, const unsigned int flags = 0);
+ Cvar(const char* name, const unsigned int flags = 0);
/*----- inspectors ------------------------------------------------ */
/// returns the name of the variable
- inline std::string const &name() { return cvar_name; }
+ inline const std::string& name() const { return cvar_name; }
/// returns the info of the variable
- inline std::string const &info() { return cvar_info; }
+ inline const std::string& info() const { return cvar_info; }
/// returns the flags of the variable
- inline unsigned int flags() const { return cvar_flags; }
+ inline const unsigned int flags() const { return cvar_flags; }
/// returns the float value of the variable
- inline float value() const { return cvar_value; }
+ inline const float value() const { return cvar_value; }
/// returns the string value of the variable
- inline const std::string &str() const { return cvar_str; }
+ inline const std::string& str() const { return cvar_str; }
/*----- mutators -------------------------------------------------- */
/// set the info string
- void set_info(const char *);
+ void set_info(const char* info);
/// char * assignment operator
- Cvar &operator=(const char *other);
+ Cvar &operator=(const char* other);
/// std::string assignment operator
- Cvar &operator=(const std::string &other);
+ Cvar &operator=(const std::string& other);
/// float assignment operator
- Cvar &operator=(float other);
+ Cvar &operator=(const float other);
/* ---- Static functions for the Cvar registry -------------------- */
/// type definition for the Cvar registry
typedef std::map<std::string, Cvar*> Registry;
- /// get a cvar value from the registry
- /** If the a cvar with the given name already exists in the registry,
- * its value will not be changed. If the cvar does not exist,
- * it will be created
- */
- static Cvar *get(const char *name, const char *value, const unsigned int flags=0);
-
- /// get a cvar value from the registry
- /** If the a cvar with the given name already exists in the registry,
- * its value will not be changed. If the cvar does not exist,
- * it will be created
- */
- static Cvar *get(const char *name, float value, const unsigned int flags=0);
-
- /// set a cvar value
- /** If the a cvar with the given name already exists in the registry,
- * its value will be replaced
- */
- static Cvar *set(const char *name, const char *value, const unsigned int flags=0);
-
- /// set a cvar value
- /** If the a cvar with the given name already exists in the registry,
- * its value will be replaced
- */
- static Cvar *set(const char *name, float value, const unsigned int flags=0);
+ /**
+ * @brief get a cvar value from the registry
+ * If the a cvar with the given name already exists in the registry,
+ * its value will not be changed. If the cvar does not exist,
+ * it will be created
+ */
+ static Cvar* get(const char* name, const char* value, const unsigned int flags=0);
- /// delete a cvar from the registry
- static void unset(const char *name);
+ /**
+ * @brief get a cvar value from the registry
+ * If the a cvar with the given name already exists in the registry,
+ * its value will not be changed. If the cvar does not exist,
+ * it will be created
+ */
+ static Cvar* get(const char* name, const float value, const unsigned int flags=0);
- /// delete a cvar from the registry
- static void unset(std::string const &name);
+ /**
+ * @brief set a cvar value
+ * If the a cvar with the given name already exists in the registry,
+ * its value will be replaced
+ */
+ static Cvar* set(const char* name, const char* value, const unsigned int flags=0);
+
+ /**
+ * @brief set a cvar value
+ * If the a cvar with the given name already exists in the registry,
+ * its value will be replaced
+ */
+ static Cvar* set(const char* name, float value, const unsigned int flags=0);
/// search for a named cvar, returns 0 if not found
- static Cvar *find(std::string const &name);
+ static Cvar* find(const std::string& name);
/// search for a named cvar, returns 0 if not found
- static Cvar *find(const char *name);
+ static Cvar* find(const char* name);
+
+ /// delete a cvar from the registry
+ static void unset(const char* name);
+
+ /// delete a cvar from the registry
+ static void unset(const std::string& name);
/// list the cvar registry
static void list();
- /// the Cvar registry
+ /// the cvar registry
static inline Registry & registry() { return cvar_registry; }
static Cvar *sv_dedicated; // dedicated server