From a265fcaf73543d028b44a10fbbca2b18979f3845 Mon Sep 17 00:00:00 2001 From: Vegard Storheil Eriksen Date: Thu, 25 Nov 2010 01:33:42 +0100 Subject: Check for valid action. --- common/action.cpp | 10 ++++++++++ common/action.h | 13 ++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 common/action.cpp (limited to 'common') 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 + +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 +#include class Action { public: @@ -35,6 +36,16 @@ class Action { } }; -typedef std::vector Actions; +//! List of actions. +class Actions : public std::vector { + public: + //! Check if specified action is present in list. + bool contains(Action action); + + template + void serialize(Archive & ar, const unsigned int version) { + ar & boost::serialization::base_object >(*this); + } +}; #endif -- cgit v1.2.3