dtkComposer.cpp 2.76 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 "dtkComposerExtension.h"
17
#include "dtkComposerSettings.h"
18
#include "dtkComposerDefaultExtensions.h"
KLOCZKO Thibaud's avatar
KLOCZKO Thibaud committed
19

20 21
namespace dtkComposer {
    namespace node {
22
        namespace _private {
23
            dtkComposerNodeFactory factory;
24
        }
WINTZ Julien's avatar
WINTZ Julien committed
25

26 27
        dtkComposerNodeFactory& factory(void)
        {
28
            return _private::factory;
29
        }
WINTZ Julien's avatar
WINTZ Julien committed
30

31 32
        void initialize(void)
        {
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
            dtkComposerBaseExtension baseExt;
            baseExt.extend(&(_private::factory));
            dtkComposerBooleanExtension boolExt;
            boolExt.extend(&(_private::factory));
            dtkComposerControlExtension controlExt;
            controlExt.extend(&(_private::factory));
            dtkComposerConstantsExtension constantsExt;
            constantsExt.extend(&(_private::factory));
            dtkComposerDistributedExtension distributedExt;
            distributedExt.extend(&(_private::factory));
            dtkComposerFileExtension fileExt;
            fileExt.extend(&(_private::factory));
            dtkComposerNumberExtension numberExt;
            numberExt.extend(&(_private::factory));
            dtkComposerStringExtension stringExt;
            stringExt.extend(&(_private::factory));
            dtkComposerContainerExtension containerExt;
            containerExt.extend(&(_private::factory));
51 52 53
        }
    }

54
    namespace extension {
55
        namespace _private {
56 57 58 59
            dtkComposerExtensionPluginFactory factory;
            dtkComposerExtensionPluginManager manager;
        }

60 61
        dtkComposerExtensionPluginFactory& pluginFactory(void)
        {
62
            return _private::factory;
63
        }
KLOCZKO Thibaud's avatar
KLOCZKO Thibaud committed
64

65 66
        dtkComposerExtensionPluginManager& pluginManager(void)
        {
67 68
            return _private::manager;
        }
69 70
        void initialize(const QString& path)
        {
71 72 73 74 75 76 77
            QString realpath = path;

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

79 80 81 82 83 84
                if (realpath.isEmpty()) {

                    realpath = QDir(DTK_INSTALL_PREFIX).filePath("plugins/dtkComposer");
                    dtkDebug() << "no composer plugin path configured, use default:" << realpath ;
                }
                pluginManager().initialize(realpath);
85 86 87 88
            } else {
                dtkDebug() << "initialize composer plugins using path:" << path ;
                pluginManager().initialize(path);
            }
89
        }
KLOCZKO Thibaud's avatar
KLOCZKO Thibaud committed
90 91
    }
}