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"
17 using namespace boost
;
19 void EngineDetails::load(Settings s
) {
22 type
= typeFromName(s
["type"].value
<QString
>());
24 s
["work-path"] >> workPath
;
27 void EngineDetails::save(Settings s
) {
30 s
["type"] = typeName(type
);
31 s
["work-path"] = workPath
;
34 void EngineInfo::playAs(Components
* components
, const IColor
* player
) {
35 if (m_token
[player
].valid()) {
36 m_ui
.removeEntity(m_token
[player
]);
37 m_token
[player
] = EntityToken();
40 m_token
[player
] = m_ui
.addPlayingEngine(player
, engine(components
));
44 // void EngineInfo::analyze() {
45 // if (m_token.valid()) {
46 // m_ui.removeAnalysingEngine(m_token);
47 // m_token = EntityToken();
50 // m_token = m_ui.addAnalysingEngine(engine());
53 EngineInfo::EngineInfo(const EngineDetails
& details
, UI
& ui
)
58 shared_ptr
<Engine
> EngineInfo::engine(Components
* components
) {
59 shared_ptr
<Engine
> res
;
60 if (m_details
.type
== EngineDetails::XBoard
)
61 res
= shared_ptr
<Engine
>(new XBoardEngine(components
, m_details
.path
, QStringList()));
62 else if (m_details
.type
== EngineDetails::GNUShogi
)
63 res
= shared_ptr
<Engine
>(new GNUShogiEngine(components
, m_details
.path
, QStringList()));
65 ERROR("Unimplemented engine type " << EngineDetails::typeName(m_details
.type
));
66 return shared_ptr
<Engine
>();
70 res
->setWorkingPath(m_details
.workPath
);