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.48 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 31 32 33
    application->setApplicationName("dtkComposerEvaluator");
    application->setApplicationVersion("1.0.0");
    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
    dtkComposer::extension::initialize();
    dtkComposer::node::initialize();
63
    dtkComposerNodeFactory *factory = &(dtkComposer::node::factory());
64

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

NICLAUSSE Nicolas's avatar
NICLAUSSE Nicolas committed
67 68 69 70 71 72 73 74 75 76 77
//         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;
//     }
78

79 80
    if (parser->isSet(slaveOption)) {
        dtkComposerEvaluatorSlave *slave = new dtkComposerEvaluatorSlave;
81

82 83 84 85
        if (!parser->isSet(serverOption)) {
            qCritical() << "Error: no server set when running as slave! Use --server <url> " ;
            return 1;
        }
86

87 88
        slave->setServer(parser->value(serverOption));
        slave->setFactory(factory);
89

90
        application->spawn();
91 92 93 94 95

        do  {
            application->exec(slave);
        } while (slave->status()  == 0);

96
        application->unspawn();
97 98

    } else {
99 100 101 102 103
        dtkComposerGraph *graph = new dtkComposerGraph;
        dtkComposerEvaluator *evaluator = new dtkComposerEvaluator;;

        evaluator->setGraph(graph);

104 105
        dtkComposerReaderNoScene *reader;
        reader = new dtkComposerReaderNoScene;
106 107 108 109 110 111
        reader->setFactory(factory);
        reader->setGraph(graph);

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

113 114 115 116
        if (!reader->read(args.first())) {
            dtkError() << "read failure for " << args.first();
            return 1;
        }
117

118 119
        if (no_gui) {
            evaluator->run_static();
NICLAUSSE Nicolas's avatar
NICLAUSSE Nicolas committed
120
            return 0;
121
        } else {
122
            QObject::connect(evaluator, SIGNAL(evaluationStopped()), qApp, SLOT(quit()));
123
            QtConcurrent::run(evaluator, &dtkComposerEvaluator::run_static, false);
NICLAUSSE Nicolas's avatar
NICLAUSSE Nicolas committed
124
            return qApp->exec();
125
        }
126 127 128
    }
}