dtkComposer.cpp 3.4 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 22 23
#if defined(DTK_BUILD_DISTRIBUTED)
#include <dtkDistributed/dtkDistributed.h>
#endif

24 25 26 27 28 29
#include <dtkCore/dtkArray.h>

namespace dtkComposer
{
    namespace node
    {
30
        namespace _private {
31
            dtkComposerNodeFactory factory;
32
        }
WINTZ Julien's avatar
WINTZ Julien committed
33

34 35
        dtkComposerNodeFactory& factory(void)
        {
36
            return _private::factory;
37
        }
WINTZ Julien's avatar
WINTZ Julien committed
38

39 40
        void initialize(void)
        {
41 42
            dtkComposerBaseExtension baseExt;
            baseExt.extend(&(_private::factory));
43

44 45
            dtkComposerBooleanExtension boolExt;
            boolExt.extend(&(_private::factory));
46

47 48
            dtkComposerControlExtension controlExt;
            controlExt.extend(&(_private::factory));
49

50 51
            dtkComposerConstantsExtension constantsExt;
            constantsExt.extend(&(_private::factory));
52

53 54 55 56
#if defined(DTK_BUILD_DISTRIBUTED)
            bool verbose = dtkComposer::extension::pluginManager().verboseLoading();
            dtkDistributed::communicator::setVerboseLoading(verbose);
            dtkDistributed::communicator::initialize();
57 58
            dtkComposerDistributedExtension distributedExt;
            distributedExt.extend(&(_private::factory));
59
#endif
60

61 62
            dtkComposerFileExtension fileExt;
            fileExt.extend(&(_private::factory));
63

64 65
            dtkComposerNumberExtension numberExt;
            numberExt.extend(&(_private::factory));
66

67 68
            dtkComposerStringExtension stringExt;
            stringExt.extend(&(_private::factory));
69

70 71
            dtkComposerContainerExtension containerExt;
            containerExt.extend(&(_private::factory));
72 73 74
        }
    }

75
    namespace extension {
76
        namespace _private {
77 78 79 80
            dtkComposerExtensionPluginFactory factory;
            dtkComposerExtensionPluginManager manager;
        }

81 82
        dtkComposerExtensionPluginFactory& pluginFactory(void)
        {
83
            return _private::factory;
84
        }
KLOCZKO Thibaud's avatar
KLOCZKO Thibaud committed
85

86 87
        dtkComposerExtensionPluginManager& pluginManager(void)
        {
88 89
            return _private::manager;
        }
90 91
        void initialize(const QString& path)
        {
92 93 94 95 96 97 98
            QString realpath = path;

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

100 101 102 103 104 105
                if (realpath.isEmpty()) {

                    realpath = QDir(DTK_INSTALL_PREFIX).filePath("plugins/dtkComposer");
                    dtkDebug() << "no composer plugin path configured, use default:" << realpath ;
                }
                pluginManager().initialize(realpath);
106 107 108 109
            } else {
                dtkDebug() << "initialize composer plugins using path:" << path ;
                pluginManager().initialize(path);
            }
110 111 112 113 114

            // needed when the composer is run on a remote node
            // should we add more ?
            qMetaTypeId< dtkArray<qlonglong>* >();
            qMetaTypeId< dtkArray<double>* >();
115
            qRegisterMetaTypeStreamOperators< QStringList* >("QStringList*");
116
        }
KLOCZKO Thibaud's avatar
KLOCZKO Thibaud committed
117 118
    }
}