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.
11 #include "agentgroup.h"
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(); \
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
, ())
55 AgentGroupDispatcher::AgentGroupDispatcher(AgentGroup
* group
, 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
);
68 bool AgentGroupDispatcher::back() {
69 m_group
->back(m_agent
);
73 bool AgentGroupDispatcher::forward() {
74 m_group
->forward(m_agent
);
78 bool AgentGroupDispatcher::gotoFirst() {
79 m_group
->gotoFirst(m_agent
);
83 bool AgentGroupDispatcher::gotoLast() {
84 m_group
->gotoLast(m_agent
);