2 Copyright (c) 2006 Paolo Capriotti <p.capriotti@gmail.com>
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 using namespace boost
;
15 void AgentGroup::addAgent(const AgentPtr
& agent
) {
16 m_agents
.insert(agent
);
19 #define FORWARD(method, args) \
20 for (weak_set<Agent>::iterator i = m_agents.begin(); \
21 i != m_agents.end(); \
23 if (i.get() != source) { \
28 void AgentGroup::clockUpdate(Agent
* source
, int white
, int black
) {
29 FORWARD(notifyClockUpdate
, (white
, black
))
32 void AgentGroup::move(Agent
* source
, const Index
& index
) {
33 FORWARD(notifyMove
, (index
))
36 void AgentGroup::back(Agent
* source
) {
37 FORWARD(notifyBack
, ())
40 void AgentGroup::forward(Agent
* source
) {
41 FORWARD(notifyForward
, ())
44 void AgentGroup::gotoFirst(Agent
* source
) {
45 FORWARD(notifyGotoFirst
, ())
48 void AgentGroup::gotoLast(Agent
* source
) {
49 FORWARD(notifyGotoLast
, ())
56 AgentGroupDispatcher::AgentGroupDispatcher(AgentGroup
* group
, Agent
* agent
)
60 void AgentGroupDispatcher::clockUpdate(int white
, int black
) {
61 m_group
->clockUpdate(m_agent
, white
, black
);
64 bool AgentGroupDispatcher::move(const Index
& index
) {
65 m_group
->move(m_agent
, index
);
69 bool AgentGroupDispatcher::back() {
70 m_group
->back(m_agent
);
74 bool AgentGroupDispatcher::forward() {
75 m_group
->forward(m_agent
);
79 bool AgentGroupDispatcher::gotoFirst() {
80 m_group
->gotoFirst(m_agent
);
84 bool AgentGroupDispatcher::gotoLast() {
85 m_group
->gotoLast(m_agent
);