summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorVegard Storheil Eriksen <zyp@jvnv.net>2010-11-25 01:33:42 +0100
committerVegard Storheil Eriksen <zyp@jvnv.net>2010-11-25 01:34:46 +0100
commita265fcaf73543d028b44a10fbbca2b18979f3845 (patch)
tree45cabd7e0ebf7318c42197b7e6207917d115251f /common
parent66940596378b502cf76ad96a5b5a1afb88378454 (diff)
Check for valid action.
Diffstat (limited to 'common')
-rw-r--r--common/action.cpp10
-rw-r--r--common/action.h13
2 files changed, 22 insertions, 1 deletions
diff --git a/common/action.cpp b/common/action.cpp
new file mode 100644
index 0000000..467df4e
--- /dev/null
+++ b/common/action.cpp
@@ -0,0 +1,10 @@
+#include "action.h"
+#include <algorithm>
+
+bool Action::operator==(Action other) {
+ return type == other.type && target == other.target;
+}
+
+bool Actions::contains(Action action) {
+ return std::find(begin(), end(), action) != end();
+}
diff --git a/common/action.h b/common/action.h
index 5099e03..bae22cf 100644
--- a/common/action.h
+++ b/common/action.h
@@ -2,6 +2,7 @@
#define ACTION_H
#include <vector>
+#include <boost/serialization/base_object.hpp>
class Action {
public:
@@ -35,6 +36,16 @@ class Action {
}
};
-typedef std::vector<Action> Actions;
+//! List of actions.
+class Actions : public std::vector<Action> {
+ public:
+ //! Check if specified action is present in list.
+ bool contains(Action action);
+
+ template<class Archive>
+ void serialize(Archive & ar, const unsigned int version) {
+ ar & boost::serialization::base_object<std::vector<Action> >(*this);
+ }
+};
#endif