Refactored TurnTest.
[tagua/yd.git] / src / engineinfo.cpp
blobd0a2e7a565035e591ef5582786ee30c0ba15ec59
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 "engineinfo.h"
12 #include "xboardengine.h"
13 #include "ui.h"
14 #include <iostream>
16 using namespace boost;
18 void EngineInfo::playAsWhite() {
19 m_ui.addPlayingEngine(0, engine());
22 void EngineInfo::playAsBlack() {
23 m_ui.addPlayingEngine(1, engine());
26 void EngineInfo::analyze() {
27 if (m_token.valid()) {
28 m_ui.removeAnalysingEngine(m_token);
29 m_token = EntityToken();
31 else
32 m_token = m_ui.addAnalysingEngine(engine());
35 EngineInfo::EngineInfo(const EngineDetails& details, UI& ui)
36 : QObject(&ui)
37 , m_details(details)
38 , m_ui(ui) { }
40 shared_ptr<Engine> EngineInfo::engine() {
41 shared_ptr<Engine> res;
42 if (m_details.type == EngineDetails::XBoard)
43 res = shared_ptr<Engine>(new XBoardEngine(m_details.path, QStringList()));
44 else {
45 ERROR("Unimplemented engine type " << EngineDetails::typeName(m_details.type));
46 return shared_ptr<Engine>();
49 if (res)
50 res->setWorkingPath(m_details.workPath);
52 return res;