Mise à jour terminée. Pour connaître les apports de la version 13.8.4 par rapport à notre ancienne version vous pouvez lire les "Release Notes" suivantes :
https://about.gitlab.com/releases/2021/02/11/security-release-gitlab-13-8-4-released/
https://about.gitlab.com/releases/2021/02/05/gitlab-13-8-3-released/

main.cpp 4.09 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
/* main.cpp ---
 *
 * Author: Nicolas Niclausse
 * Copyright (C) 2014 - Nicolas Niclausse, Inria.
 * Created: 2014/10/28 12:45:34
 */

/* Commentary:
 *
 */

/* Change log:
 *
 */



18 19 20

#include <dtkDistributed>
#include <dtkComposer>
NICLAUSSE Nicolas's avatar
NICLAUSSE Nicolas committed
21 22 23 24
#include <dtkCore>

#include <dtkCoreSupport/dtkPluginManager.h>
#include <dtkCoreSupport/dtkAbstractProcessFactory.h>
25 26 27 28 29

#include <QtConcurrent>

int main(int argc, char **argv)
{
NICLAUSSE Nicolas's avatar
NICLAUSSE Nicolas committed
30
    dtkDistributedApplication *application = dtkDistributed::create(argc, argv);
31

NICLAUSSE Nicolas's avatar
NICLAUSSE Nicolas committed
32 33 34 35 36
    application->setApplicationName("dtkComposerEvaluator");
    application->setApplicationVersion("1.0.0");
    application->setOrganizationName("inria");
    application->setOrganizationDomain("fr");
    bool no_gui = dtkDistributed::app()->noGui();
37

NICLAUSSE Nicolas's avatar
NICLAUSSE Nicolas committed
38 39
    QCommandLineParser *parser = application->parser();
    parser->setApplicationDescription("DTK composer evaluator. Run the given compostion (XML file).");
40 41 42 43 44

    // /////////////////////////////////////////////////////////////////
    // Arguments & Options
    // /////////////////////////////////////////////////////////////////

NICLAUSSE Nicolas's avatar
NICLAUSSE Nicolas committed
45 46
    QCommandLineOption pgOption("pg", "enable profiling");
    parser->addOption(pgOption);
47 48 49 50 51 52 53

    QCommandLineOption slaveOption("slave", "run as a dtk distributed slave instance");
    parser->addOption(slaveOption);

    QCommandLineOption serverOption("server", "DTK distributed server URL", "URL");
    parser->addOption(serverOption);

NICLAUSSE Nicolas's avatar
NICLAUSSE Nicolas committed
54
    application->initialize();
55

NICLAUSSE Nicolas's avatar
NICLAUSSE Nicolas committed
56
    QStringList args = parser->positionalArguments();
57

58
    if (args.isEmpty() && !parser->isSet(slaveOption)) {
59
        qDebug() << "Usage: " << argv[0] << "--spawn | [-pg] <composition> ";
NICLAUSSE Nicolas's avatar
NICLAUSSE Nicolas committed
60
        return 1;
61 62
    }

NICLAUSSE Nicolas's avatar
NICLAUSSE Nicolas committed
63 64 65
    // /////////////////////////////////////////////////////////////////
    // Old Plugin manager initialization
    // /////////////////////////////////////////////////////////////////
66

67 68
    // QSettings *main_settings = application->settings();
    // main_settings->beginGroup("plugins");
69

70 71 72
    // if (main_settings->contains("path")) {
    //     dtkPluginManager::instance()->setPath(main_settings->value("path").toString());
    // }
73

74 75 76
    // if (parser->isSet("verbose")) {
    //     dtkPluginManager::instance()->setVerboseLoading(true);
    // }
77

78 79
    // main_settings->endGroup();
    // dtkPluginManager::instance()->initialize();
80

81
    dtkComposerFactory *factory = dtkComposerFactory::instance();
82

NICLAUSSE Nicolas's avatar
NICLAUSSE Nicolas committed
83
//     if (args[1] == "--spawn") {
84

NICLAUSSE Nicolas's avatar
NICLAUSSE Nicolas committed
85 86 87 88 89 90 91 92 93 94 95
//         dtkComposerEvaluatorProcess p;
// //        p.setInternalCommunicator(comm);
//         p.setParentCommunicator(policy.communicator());
//         p.setFactory(factory);
//         p.setApplication("dtkComposerEvaluator");

//         int value;
//         do  { value = p.exec(); } while (value  == 0);

//         return value;
//     }
96

97 98 99 100 101 102 103 104
    if (parser->isSet(slaveOption)) {
        dtkComposerEvaluatorSlave *slave = new dtkComposerEvaluatorSlave;
        if (!parser->isSet(serverOption)) {
            qCritical() << "Error: no server set when running as slave! Use --server <url> " ;
            return 1;
        }
        slave->setServer(parser->value(serverOption));
        slave->setFactory(factory);
105

106 107 108
        application->spawn();
        do  { application->exec(slave); } while (slave->status()  == 0);
        application->unspawn();
109 110

    } else {
111 112 113 114 115
        dtkComposerGraph *graph = new dtkComposerGraph;
        dtkComposerEvaluator *evaluator = new dtkComposerEvaluator;;

        evaluator->setGraph(graph);

116 117
        dtkComposerReaderNoScene *reader;
        reader = new dtkComposerReaderNoScene;
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134
        reader->setFactory(factory);
        reader->setGraph(graph);

        if (parser->isSet(pgOption)) {
            evaluator->setProfiling(true);
        }
        if (!reader->read(args.first())) {
            dtkError() << "read failure for " << args.first();
            return 1;
        }
        if (no_gui) {
            evaluator->run_static();
        } else {
            QObject::connect(evaluator,SIGNAL(evaluationStopped()),qApp, SLOT(quit()));
            QtConcurrent::run(evaluator, &dtkComposerEvaluator::run_static, false);
            qApp->exec();
        }
135
    }
NICLAUSSE Nicolas's avatar
NICLAUSSE Nicolas committed
136
    dtkPluginManager::instance()->uninitialize();
137 138
}