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.
12 #include "hlvariant/tagua_wrapped.h"
13 #include "hlvariant/chess/variant.h"
14 #include "hlvariant/crazyhouse/variant.h"
15 #include "hlvariant/dummy/variant.h"
16 #include "hlvariant/minichess5/variant.h"
17 #include "hlvariant/shogi/variant.h"
18 #include "hlvariant/minishogi/variant.h"
20 using namespace HLVariant
;
22 template <typename Variant
>
23 void register_variant(Variants
* variants
) {
26 new WrappedVariantFactory
<Variant
>);
30 Variants::Variants() {
31 register_variant
<Chess::Variant
>(this);
32 register_variant
<Minichess5::Variant
>(this);
33 register_variant
<Crazyhouse::Variant
>(this);
34 register_variant
<Dummy::Variant
>(this);
35 register_variant
<Shogi::Variant
>(this);
36 register_variant
<MiniShogi::Variant
>(this);
39 Variants
& Variants::instance() {
44 VariantFactory
* Variants::getFactory(const QString
& name
) const {
45 Factories::const_iterator it
= m_factories
.find(name
);
46 if (it
!= m_factories
.end()) {
53 VariantPtr
Variants::get(const QString
& name
) const {
54 VariantFactory
* factory
= getFactory(name
);
55 return factory
? VariantPtr(factory
->createVariant()) : VariantPtr();
58 void Variants::addFactory(const QString
& name
, VariantFactory
* factory
) {
59 m_factories
[name
] = factory
;
60 std::cout
<< "added factory for variant " << name
<< std::endl
;
63 QStringList
Variants::all() const {
65 for (Factories::const_iterator end
= m_factories
.end(), it
= m_factories
.begin(); it
!= end
; ++it
) {