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 3.57 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
#include <dtkCore>
22
#include <dtkWidgets>
NICLAUSSE Nicolas's avatar
NICLAUSSE Nicolas committed
23

24 25 26 27
#include <QtConcurrent>

int main(int argc, char **argv)
{
28
    dtkDistributedGuiApplication *application = dtkDistributedGuiApplication::create(argc, argv);
29

NICLAUSSE Nicolas's avatar
NICLAUSSE Nicolas committed
30
    application->setApplicationName("dtkComposerEvaluator");
NICLAUSSE Nicolas's avatar
NICLAUSSE Nicolas committed
31
    application->setApplicationVersion("1.5.1");
NICLAUSSE Nicolas's avatar
NICLAUSSE Nicolas committed
32 33
    application->setOrganizationName("inria");
    application->setOrganizationDomain("fr");
34
    bool no_gui = application->noGui();
35

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

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

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

    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
52
    application->initialize();
53

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

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

61 62 63 64 65
    QCommandLineOption verboseOption("verbose", QCoreApplication::translate("main", "verbose plugin initialization"));

    if (parser->isSet(verboseOption)) {
        dtkComposer::extension::pluginManager().setVerboseLoading(true);
    }
66 67
    dtkComposer::extension::initialize();
    dtkComposer::node::initialize();
68
    dtkComposerNodeFactory *factory = &(dtkComposer::node::factory());
69

70 71
    if (parser->isSet(slaveOption)) {
        dtkComposerEvaluatorSlave *slave = new dtkComposerEvaluatorSlave;
72

73 74 75 76
        if (!parser->isSet(serverOption)) {
            qCritical() << "Error: no server set when running as slave! Use --server <url> " ;
            return 1;
        }
77

78 79
        slave->setServer(parser->value(serverOption));
        slave->setFactory(factory);
80 81 82 83 84 85 86 87
        QCommandLineOption policyOption("policy", "dtkDistributed policy (default is qthread)", "qthread|mpi|mpi3");
        if (parser->isSet(policyOption)) {
            application->spawn();
            do  { application->exec(slave); } while (slave->status()  == 0);
            application->unspawn();
        } else {
            do  { slave->run(); } while (slave->status()  == 0);
        }
88 89

    } else {
90 91 92 93 94
        dtkComposerGraph *graph = new dtkComposerGraph;
        dtkComposerEvaluator *evaluator = new dtkComposerEvaluator;;

        evaluator->setGraph(graph);

95 96
        dtkComposerReaderNoScene *reader;
        reader = new dtkComposerReaderNoScene;
97 98 99 100 101 102
        reader->setFactory(factory);
        reader->setGraph(graph);

        if (parser->isSet(pgOption)) {
            evaluator->setProfiling(true);
        }
103

104 105 106 107
        if (!reader->read(args.first())) {
            dtkError() << "read failure for " << args.first();
            return 1;
        }
108

109 110
        if (no_gui) {
            evaluator->run_static();
NICLAUSSE Nicolas's avatar
NICLAUSSE Nicolas committed
111
            return 0;
112
        } else {
113
            QObject::connect(evaluator, SIGNAL(evaluationStopped()), qApp, SLOT(quit()));
114
            QtConcurrent::run(evaluator, &dtkComposerEvaluator::run_static, false);
NICLAUSSE Nicolas's avatar
NICLAUSSE Nicolas committed
115
            return qApp->exec();
116
        }
117 118
    }
}