removed clock pref widget. clock prefs are definitively part of the lua theme.
[kboard.git] / src / agentgroup.cpp
blobd8f16291186ee98fe3f5b3a115101afc78431ca8
1 /*
2 Copyright (c) 2006 Paolo Capriotti <p.capriotti@sns.it>
3 (c) 2006 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.
9 */
11 #include "agentgroup.h"
12 #include <functional>
13 #include <boost/bind.hpp>
15 using namespace boost;
17 void AgentGroup::addAgent(const AgentPtr& agent) {
18 m_agents.insert(agent);
21 #define FORWARD(method, args) \
22 for (weak_set<Agent>::iterator i = m_agents.begin(); \
23 i != m_agents.end(); \
24 ++i) { \
25 if (i.get() != source) i->method args; \
27 void AgentGroup::clockUpdate(Agent* source, int white, int black) {
28 FORWARD(notifyClockUpdate, (white, black))
31 void AgentGroup::move(Agent* source, AbstractMove::Ptr move, AbstractPosition::Ptr ref) {
32 FORWARD(notifyMove, (move, ref))
35 void AgentGroup::back(Agent* source) {
36 FORWARD(notifyBack, ())
39 void AgentGroup::forward(Agent* source) {
40 FORWARD(notifyForward, ())
43 void AgentGroup::gotoFirst(Agent* source) {
44 FORWARD(notifyGotoFirst, ())
47 void AgentGroup::gotoLast(Agent* source) {
48 FORWARD(notifyGotoLast, ())
50 #undef FORWARD
55 AgentGroupDispatcher::AgentGroupDispatcher(AgentGroup* group, Agent* agent)
56 : m_group(group)
57 , m_agent(agent) { }
59 void AgentGroupDispatcher::clockUpdate(int white, int black) {
60 m_group->clockUpdate(m_agent, white, black);
63 bool AgentGroupDispatcher::move(AbstractMove::Ptr move, AbstractPosition::Ptr ref) {
64 m_group->move(m_agent, move, ref);
65 return true;
68 bool AgentGroupDispatcher::back() {
69 m_group->back(m_agent);
70 return true;
73 bool AgentGroupDispatcher::forward() {
74 m_group->forward(m_agent);
75 return true;
78 bool AgentGroupDispatcher::gotoFirst() {
79 m_group->gotoFirst(m_agent);
80 return true;
83 bool AgentGroupDispatcher::gotoLast() {
84 m_group->gotoLast(m_agent);
85 return true;