summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorVegard Storheil Eriksen <zyp@jvnv.net>2010-11-25 11:12:43 +0100
committerVegard Storheil Eriksen <zyp@jvnv.net>2010-11-25 11:12:43 +0100
commit8809e34f9d9241c39ee067de25d968bea887783f (patch)
tree4be6de2d80936bed35ac1d386db71b3dd3cda747 /common
parentfa8f99cb63cd04bb8006e3f568d7f2494723528f (diff)
Add Action() taking type and target and Actions::operator bool().
Diffstat (limited to 'common')
-rw-r--r--common/action.cpp12
-rw-r--r--common/action.h6
2 files changed, 18 insertions, 0 deletions
diff --git a/common/action.cpp b/common/action.cpp
index 188535e..58b7392 100644
--- a/common/action.cpp
+++ b/common/action.cpp
@@ -1,10 +1,22 @@
#include "action.h"
#include <algorithm>
+Action::Action() {
+
+}
+
+Action::Action(Type ty, int ta) : type(ty), target(ta) {
+
+}
+
bool Action::operator==(const Action& other) {
return type == other.type && target == other.target;
}
+Actions::operator bool() {
+ return !empty();
+}
+
bool Actions::contains(Action action) {
return std::find(begin(), end(), action) != end();
}
diff --git a/common/action.h b/common/action.h
index a2dc6e4..4024c67 100644
--- a/common/action.h
+++ b/common/action.h
@@ -25,6 +25,9 @@ class Action {
//! Target of action (if applicable).
int target;
+ Action();
+ Action(Type ty, int ta = 0);
+
//! Compare to another action.
bool operator==(const Action& other);
@@ -41,6 +44,9 @@ class Actions : public std::vector<Action> {
//! Check if specified action is present in list.
bool contains(Action action);
+ //! Check whether list is empty or not.
+ operator bool();
+
template<class Archive>
void serialize(Archive & ar, const unsigned int version) {
ar & boost::serialization::base_object<std::vector<Action> >(*this);