Update for doxygen 1.5.5, graph generation, and match current code.
[tagua/yd.git] / src / engineinfo.cpp
blob92da80d7906694180b17524ed6e7819efcca55fa
1 /*
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.
9 */
11 #include "engineinfo.h"
12 #include "xboardengine.h"
13 #include "gnushogiengine.h"
14 #include "ui.h"
15 #include "core/color.h"
16 #include <KDebug>
18 using namespace boost;
20 void EngineDetails::load(Settings s) {
21 s["name"] >> name;
22 s["path"] >> path;
23 type = typeFromName(s["type"].value<QString>());
24 if (s["work-path"])
25 s["work-path"] >> workPath;
28 void EngineDetails::save(Settings s) {
29 s["name"] = name;
30 s["path"] = path;
31 s["type"] = typeName(type);
32 s["work-path"] = workPath;
35 void EngineInfo::playAs(Components* components, const IColor* player) {
36 if (m_token[player].valid()) {
37 m_ui.removeEntity(m_token[player]);
38 m_token[player] = EntityToken();
40 else {
41 m_token[player] = m_ui.addPlayingEngine(player, engine(components, player->index()));
45 // void EngineInfo::analyze() {
46 // if (m_token.valid()) {
47 // m_ui.removeAnalysingEngine(m_token);
48 // m_token = EntityToken();
49 // }
50 // else
51 // m_token = m_ui.addAnalysingEngine(engine());
52 // }
54 EngineInfo::EngineInfo(const EngineDetails& details, UI& ui)
55 : QObject(&ui)
56 , m_details(details)
57 , m_ui(ui) { }
59 shared_ptr<Engine> EngineInfo::engine(Components* components, int player) {
60 shared_ptr<Engine> res;
61 if (m_details.type == EngineDetails::XBoard)
62 res = shared_ptr<Engine>(new XBoardEngine(components, m_details.path, QStringList()));
63 else if (m_details.type == EngineDetails::GNUShogi)
64 res = shared_ptr<Engine>(new GNUShogiEngine(components, m_details.path, QStringList()));
65 else {
66 kError() << "Unimplemented engine type" << EngineDetails::typeName(m_details.type);
67 return shared_ptr<Engine>();
70 if (res) {
71 res->setWorkingPath(m_details.workPath);
72 res->setSide(player);
75 return res;