Allow building as monolithic app (no plugins) for easier developement.
[tagua.git] / src / engineinfo.h
blobcf0a292522284fda4d444b0266443464c475ed02
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 #ifndef ENGINEINFO_H
12 #define ENGINEINFO_H
14 #include <map>
15 #include <QString>
16 #include <QObject>
17 #include <boost/shared_ptr.hpp>
18 #include "controllers/entitytoken.h"
19 #include "settings.h"
21 class Components;
22 class Engine;
23 class IColor;
24 class UI;
26 struct EngineDetails {
27 enum EngineType {
28 XBoard,
29 UCI,
30 TaguaText,
31 TaguaDBUS,
32 GNUShogi,
33 Unknown
36 QString name;
37 QString path;
38 EngineType type;
39 QString workPath;
41 EngineDetails(const QString& name, const QString& path, const EngineType& type)
42 : name(name), path(path), type(type) { }
43 EngineDetails() { }
45 static QString typeName(EngineType t) {
46 switch (t) {
47 case XBoard:
48 return "xboard";
49 case UCI:
50 return "UCI";
51 case TaguaText:
52 return "tagua-text";
53 case TaguaDBUS:
54 return "tagua-dbus";
55 case GNUShogi:
56 return "gnushogi";
57 default:
58 return "unknown";
62 static EngineType typeFromName(const QString& name) {
63 if (name == "xboard")
64 return XBoard;
65 else if (name == "UCI")
66 return UCI;
67 else if (name == "tagua-text")
68 return TaguaText;
69 else if (name == "tagua-dbus")
70 return TaguaDBUS;
71 else if (name == "gnushogi")
72 return GNUShogi;
73 else return Unknown;
76 void load(Settings s);
77 void save(Settings s);
80 class EngineInfo : public QObject {
81 Q_OBJECT
82 EngineDetails m_details;
83 UI& m_ui;
84 typedef std::map<const IColor*, EntityToken> Tokens;
85 Tokens m_token;
86 protected:
87 virtual boost::shared_ptr<Engine> engine(Components* components, int player);
88 void playAs(Components* components, const IColor* player);
89 public:
90 EngineInfo(const EngineDetails& details, UI& ui);
91 void setWorkPath(const QString& wp) { m_details.workPath = wp; }
94 #endif // ENGINEINFO_H