2 Copyright (c) 2007 Paolo Capriotti <p.capriotti@sns.it>
3 (c) 2007 Maurizio Monge <maurizio.monge@kdemail.net>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
11 #include "turnpolicy.h"
13 namespace TurnPolicy
{
15 Abstract::~Abstract() { }
17 class Simple
: public Abstract
{
20 Simple(bool value
) : m_value(value
) { }
21 bool check() const { return m_value
; }
24 Premove::~Premove() { }
26 bool Collection::operator()(int turn
) const {
27 Policies::const_iterator it
= m_policies
.find(turn
);
28 if (it
== m_policies
.end()) {
32 return it
->second
->check();
36 void Collection::setPolicy(int turn
, const PolicyPtr
& policy
) {
37 m_policies
[turn
] = policy
;
40 void Collection::setSimplePolicy(int turn
, bool value
) {
41 setPolicy(turn
, boost::shared_ptr
<Simple
>(new Simple(value
)));
44 void Collection::clear() {
49 bool Collection::premove() const {
50 return m_premove
? m_premove
->check() : false;
53 void Collection::setPremovePolicy(const PremovePolicyPtr
& policy
) {