summaryrefslogtreecommitdiff
path: root/src/event.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/event.h')
-rw-r--r--src/event.h91
1 files changed, 84 insertions, 7 deletions
diff --git a/src/event.h b/src/event.h
index 1e057a05..7acd2190 100644
--- a/src/event.h
+++ b/src/event.h
@@ -40,33 +40,110 @@ typedef std::map<std::string, VariableData *> VariableMap;
class Event
{
public:
- // String passed can be retivered with getName()
- // and is to used to identify what type of event
- // this is.
+ /**
+ * Makes an event with the given name.
+ */
Event(const std::string &name)
{ mEventName = name; }
~Event();
+ /**
+ * Returns the name of the event.
+ */
const std::string &getName() const
{ return mEventName; }
- // Sets or gets a interger with a key to identify
+ /**
+ * Sets the given variable to the given integer, if it isn't already set.
+ */
void setInt(const std::string &key, int value) throw (BadEvent);
+
+ /**
+ * Returns the given variable if it is set and an integer.
+ */
int getInt(const std::string &key) const throw (BadEvent);
- // Sets or gets a string with a key to identify
+ /**
+ * Returns the given variable if it is set and an integer, returning the
+ * given default otherwise.
+ */
+ inline int getInt(const std::string &key, int defaultValue) const
+ { try { return getInt(key); } catch (BadEvent) { return defaultValue; }}
+
+ /**
+ * Returns true if the given variable exists and is an integer.
+ */
+ bool hasInt(const std::string &key);
+
+ /**
+ * Sets the given variable to the given string, if it isn't already set.
+ */
void setString(const std::string &key, const std::string &value) throw (BadEvent);
+
+ /**
+ * Returns the given variable if it is set and a string.
+ */
const std::string &getString(const std::string &key) const throw (BadEvent);
- // Sets or gets a floating point number with key to identify
+ /**
+ * Returns the given variable if it is set and a string, returning the
+ * given default otherwise.
+ */
+ inline const std::string &getString(const std::string &key,
+ const std::string &defaultValue) const
+ { try { return getString(key); } catch (BadEvent) { return defaultValue; }}
+
+ /**
+ * Returns true if the given variable exists and is a string.
+ */
+ bool hasString(const std::string &key);
+
+ /**
+ * Sets the given variable to the given floating-point, if it isn't already
+ * set.
+ */
void setFloat(const std::string &key, double value) throw (BadEvent);
+
+ /**
+ * Returns the given variable if it is set and a floating-point.
+ */
double getFloat(const std::string &key) const throw (BadEvent);
- // Sets or gets a boolean with key to identify
+ /**
+ * Returns the given variable if it is set and a floating-point, returning
+ * the given default otherwise.
+ */
+ inline double getFloat(const std::string &key, float defaultValue) const
+ { try { return getFloat(key); } catch (BadEvent) { return defaultValue; }}
+
+ /**
+ * Returns true if the given variable exists and is a floating-point.
+ */
+ bool hasFloat(const std::string &key);
+
+ /**
+ * Sets the given variable to the given boolean, if it isn't already set.
+ */
void setBool(const std::string &key, bool value) throw (BadEvent);
+
+ /**
+ * Returns the given variable if it is set and a boolean.
+ */
bool getBool(const std::string &key) const throw (BadEvent);
+ /**
+ * Returns the given variable if it is set and a boolean, returning the
+ * given default otherwise.
+ */
+ inline bool getBool(const std::string &key, bool defaultValue) const
+ { try { return getBool(key); } catch (BadEvent) { return defaultValue; }}
+
+ /**
+ * Returns true if the given variable exists and is a boolean.
+ */
+ bool hasBool(const std::string &key);
+
private:
std::string mEventName;