dtkComposer.cpp 2.3 KB
Newer Older
KLOCZKO Thibaud's avatar
KLOCZKO Thibaud committed
1
/* dtkComposer.cpp ---
2
 *
KLOCZKO Thibaud's avatar
KLOCZKO Thibaud committed
3 4 5 6 7
 * Author: Thibaud Kloczko
 * Created: Tue Apr  9 12:49:06 2013 (+0200)
 */

/* Change Log:
8
 *
KLOCZKO Thibaud's avatar
KLOCZKO Thibaud committed
9 10 11
 */

#include "dtkComposer.h"
12 13 14

#include <dtkConfig.h>

KLOCZKO Thibaud's avatar
KLOCZKO Thibaud committed
15
#include "dtkComposerNodeFactory.h"
16
#include "dtkComposerFactoryManager.h"
17
#include "dtkComposerExtension.h"
18
#include "dtkComposerSettings.h"
KLOCZKO Thibaud's avatar
KLOCZKO Thibaud committed
19 20 21

namespace dtkComposer
{
22
    namespace node
23
    {
24 25 26
        namespace _private {
            dtkComposerFactoryManager manager;
        }
27
        dtkComposerNodeFactory *factory(void) {
28 29 30 31 32 33 34 35 36 37 38 39
            return _private::manager.factory();
        }
        void initialize(void) {
            _private::manager.initNodeBase();
            _private::manager.initNodeBoolean();
            _private::manager.initNodeControl();
            _private::manager.initNodeConstants();
            _private::manager.initNodeDistributed();
            _private::manager.initNodeFile();
            _private::manager.initNodeNumber();
            _private::manager.initNodeString();
            _private::manager.initNodeContainer();
40 41 42 43
        }
    }

    namespace extension
KLOCZKO Thibaud's avatar
KLOCZKO Thibaud committed
44
    {
45
        namespace _private {
46 47 48 49 50 51
            dtkComposerExtensionPluginFactory factory;
            dtkComposerExtensionPluginManager manager;
        }

        dtkComposerExtensionPluginFactory& pluginFactory(void) {
            return _private::factory;
52
        }
KLOCZKO Thibaud's avatar
KLOCZKO Thibaud committed
53

54 55 56 57
        dtkComposerExtensionPluginManager& pluginManager(void) {
            return _private::manager;
        }
        void initialize(const QString& path) {
58 59 60 61 62 63 64 65 66 67 68 69
            QString realpath = path;

            if (realpath.isEmpty()) {
                dtkComposerSettings composer_settings;
                composer_settings.beginGroup("extension");
                realpath = composer_settings.value("plugins").toString();
                composer_settings.endGroup();
                if (realpath.isEmpty()) {

                    realpath = QDir(DTK_INSTALL_PREFIX).filePath("plugins/dtkComposer");
                    dtkDebug() << "no composer plugin path configured, use default:" << realpath ;
                }
70
                pluginManager().setVerboseLoading(true);
71
                pluginManager().initialize(realpath);
72 73 74 75
            } else {
                dtkDebug() << "initialize composer plugins using path:" << path ;
                pluginManager().initialize(path);
            }
76
        }
KLOCZKO Thibaud's avatar
KLOCZKO Thibaud committed
77 78
    }
}