dtkComposer.cpp 3.79 KB
Newer Older
1
2
3
// Version: $Id$
//
//
KLOCZKO Thibaud's avatar
KLOCZKO Thibaud committed
4

5
6
7
// Commentary:
//
//
KLOCZKO Thibaud's avatar
KLOCZKO Thibaud committed
8

9
10
11
12
13
// Change Log:
//
//

// Code:
14
15
16

#include <dtkConfig.h>

17
#include "dtkComposer.h"
KLOCZKO Thibaud's avatar
KLOCZKO Thibaud committed
18
#include "dtkComposerNodeFactory.h"
19
#include "dtkComposerExtension.h"
20
#include "dtkComposerSettings.h"
21
#include "dtkComposerDefaultExtensions.h"
KLOCZKO Thibaud's avatar
KLOCZKO Thibaud committed
22

23
24
#include <dtkCore/dtkArray.h>

25
26
27
28
#if defined(DTK_BUILD_DISTRIBUTED)
#include <dtkDistributed/dtkDistributed.h>
#endif

29
30
31
32
namespace dtkComposer
{
    namespace node
    {
33
        namespace _private {
34
            dtkComposerNodeFactory factory;
35
        }
Julien Wintz's avatar
Julien Wintz committed
36

37
38
        dtkComposerNodeFactory& factory(void)
        {
39
            return _private::factory;
40
        }
Julien Wintz's avatar
Julien Wintz committed
41

42
43
        void initialize(void)
        {
44
45
            dtkComposerBaseExtension baseExt;
            baseExt.extend(&(_private::factory));
46

47
48
            dtkComposerBooleanExtension boolExt;
            boolExt.extend(&(_private::factory));
49

50
51
            dtkComposerControlExtension controlExt;
            controlExt.extend(&(_private::factory));
52

53
54
            dtkComposerConstantsExtension constantsExt;
            constantsExt.extend(&(_private::factory));
55

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

64
65
            dtkComposerFileExtension fileExt;
            fileExt.extend(&(_private::factory));
66

67
68
            dtkComposerNumberExtension numberExt;
            numberExt.extend(&(_private::factory));
69

70
71
            dtkComposerStringExtension stringExt;
            stringExt.extend(&(_private::factory));
72

73
74
            dtkComposerContainerExtension containerExt;
            containerExt.extend(&(_private::factory));
75
76
77
        }
    }

78
    namespace extension {
79

80
        namespace _private {
81
82
            dtkComposerExtensionPluginFactory factory;
            dtkComposerExtensionPluginManager manager;
83
            bool activate_obj_mgr = false;
84
85
        }

86
87
        dtkComposerExtensionPluginFactory& pluginFactory(void)
        {
88
            return _private::factory;
89
        }
KLOCZKO Thibaud's avatar
KLOCZKO Thibaud committed
90

91
92
        dtkComposerExtensionPluginManager& pluginManager(void)
        {
93
94
            return _private::manager;
        }
95

96
97
98
99
100
101
102
103
104
105
106
107
        void activateObjectManager(bool val)
        {
            qDebug() << "set activate object manager to:" << val;
            _private::activate_obj_mgr = val;
        }

        bool isObjectManagerActive(void)
        {
            qDebug() << "is active object manager ?" << _private::activate_obj_mgr ;
            return _private::activate_obj_mgr ;
        }

108
109
        void initialize(const QString& path)
        {
110
111
112
113
114
115
116
            QString realpath = path;

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

118
119
120
121
122
123
                if (realpath.isEmpty()) {

                    realpath = QDir(DTK_INSTALL_PREFIX).filePath("plugins/dtkComposer");
                    dtkDebug() << "no composer plugin path configured, use default:" << realpath ;
                }
                pluginManager().initialize(realpath);
124
125
126
127
            } else {
                dtkDebug() << "initialize composer plugins using path:" << path ;
                pluginManager().initialize(path);
            }
128
129
130

            // needed when the composer is run on a remote node
            // should we add more ?
131
132
133
            qMetaTypeId<dtkArray<qlonglong> *>();
            qMetaTypeId<dtkArray<double> *>();
            qRegisterMetaTypeStreamOperators<QStringList *>("QStringList *");
134
        }
KLOCZKO Thibaud's avatar
KLOCZKO Thibaud committed
135
136
    }
}
137
138
139

//
// dtkComposer.cpp ends here