Allow building as monolithic app (no plugins) for easier developement.
[tagua.git] / src / variantfactory.cpp
blobcc2555455e6f73f7496a9f5ff560e96096716d05
1 /*
2 Copyright (c) 2006 Paolo Capriotti <p.capriotti@gmail.com>
3 (c) 2006 Maurizio Monge <maurizio.monge@kdemail.net>
4 (c) 2008 Yann Dirson <ydirson@altern.org>
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
12 #include "variantfactory.h"
13 #include <memory>
14 #include <KDebug>
15 #include "foreach.h"
16 #include "variant.h"
17 #include "variantfactories/kdepluginvariants.h"
18 #ifdef TAGUA_MONOLITH
19 # include "variantfactories/builtinvariants.h"
20 #endif
22 void load_plugins();
24 VariantFactory::VariantFactory() { }
26 VariantFactory& VariantFactory::self() {
27 static VariantFactory inst;
28 return inst;
31 Variant* VariantFactory::create(const QString& name) {
32 Variant* v = NULL;
33 #ifdef TAGUA_MONOLITH
34 if (v == NULL)
35 v = BuiltinVariants::self().create(name);
36 #endif
37 if (v == NULL)
38 v = KDEPluginVariants::self().create(name);
39 if (v == NULL)
40 kFatal() << "failed to create variant" << name;
41 return v;
44 QStringList VariantFactory::all() const {
45 QStringList l = KDEPluginVariants::self().all();
46 #ifdef TAGUA_MONOLITH
47 l << BuiltinVariants::self().all();
48 #endif
49 return l;
52 Repository* VariantFactory::getRepository(const QString& variant) {
53 Repository* r = NULL;
54 #ifdef TAGUA_MONOLITH
55 if (r == NULL)
56 r = BuiltinVariants::self().getRepository(variant);
57 #endif
58 if (r == NULL)
59 r = KDEPluginVariants::self().getRepository(variant);
60 return r;