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 "engineinfo.h"
12 #include "xboardengine.h"
13 #include "gnushogiengine.h"
15 #include "core/color.h"
18 using namespace boost
;
20 void EngineDetails::load(Settings s
) {
23 type
= typeFromName(s
["type"].value
<QString
>());
25 s
["work-path"] >> workPath
;
28 void EngineDetails::save(Settings s
) {
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();
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();
51 // m_token = m_ui.addAnalysingEngine(engine());
54 EngineInfo::EngineInfo(const EngineDetails
& details
, 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()));
66 kError() << "Unimplemented engine type" << EngineDetails::typeName(m_details
.type
);
67 return shared_ptr
<Engine
>();
71 res
->setWorkingPath(m_details
.workPath
);