Changeset View
Changeset View
Standalone View
Standalone View
src/backends/julia/juliaserver/juliaserver.h
Show All 16 Lines | |||||
17 | * --- | 17 | * --- | ||
18 | * Copyright (C) 2016 Ivan Lakhtanov <ivan.lakhtanov@gmail.com | 18 | * Copyright (C) 2016 Ivan Lakhtanov <ivan.lakhtanov@gmail.com | ||
19 | */ | 19 | */ | ||
20 | #pragma once | 20 | #pragma once | ||
21 | 21 | | |||
22 | #include <QObject> | 22 | #include <QObject> | ||
23 | #include <QString> | 23 | #include <QString> | ||
24 | 24 | | |||
25 | /** | ||||
26 | * Implementation of command execution server with DBus interface for Julia | ||||
27 | * language. | ||||
28 | * | ||||
29 | * Uses Julia embedding | ||||
30 | * http://docs.julialang.org/en/release-0.4/manual/embedding/ to get results. | ||||
31 | */ | ||||
25 | class JuliaServer: public QObject | 32 | class JuliaServer: public QObject | ||
26 | { | 33 | { | ||
27 | Q_OBJECT | 34 | Q_OBJECT | ||
28 | public: | 35 | public: | ||
29 | JuliaServer(QObject *parent = nullptr); | 36 | JuliaServer(QObject *parent = nullptr); | ||
30 | 37 | | |||
31 | virtual ~JuliaServer(); | 38 | virtual ~JuliaServer(); | ||
32 | 39 | | |||
33 | public Q_SLOTS: | 40 | public Q_SLOTS: | ||
41 | /** | ||||
42 | * Initializer for JuliaServer. Call this first before using it | ||||
43 | * | ||||
44 | * @param path path to julia executable | ||||
45 | */ | ||||
34 | Q_SCRIPTABLE void login(const QString &path) const; | 46 | Q_SCRIPTABLE void login(const QString &path) const; | ||
47 | | ||||
48 | /** | ||||
49 | * Runs a piece of julia code. After this returns use getOutput, getError, | ||||
50 | * getWasException methods to retrieve execution result. | ||||
51 | * | ||||
52 | * @param command maybe multiline piece of julia code to run | ||||
53 | */ | ||||
35 | Q_SCRIPTABLE void runJuliaCommand(const QString &command); | 54 | Q_SCRIPTABLE void runJuliaCommand(const QString &command); | ||
55 | | ||||
56 | /** | ||||
57 | * @return stdout output of the last command execution | ||||
58 | */ | ||||
36 | Q_SCRIPTABLE QString getOutput() const; | 59 | Q_SCRIPTABLE QString getOutput() const; | ||
60 | | ||||
61 | /** | ||||
62 | * @return stderr output of the last command exection | ||||
63 | */ | ||||
37 | Q_SCRIPTABLE QString getError() const; | 64 | Q_SCRIPTABLE QString getError() const; | ||
65 | | ||||
66 | /** | ||||
67 | * @return indicator that exception was triggered during last command | ||||
68 | * execution | ||||
69 | */ | ||||
38 | Q_SCRIPTABLE bool getWasException() const; | 70 | Q_SCRIPTABLE bool getWasException() const; | ||
39 | 71 | | |||
40 | private: | 72 | private: | ||
41 | QString m_error; | 73 | QString m_error; //< Stores last stderr output | ||
42 | QString m_output; | 74 | QString m_output; //< Stores last stdout output | ||
43 | bool m_was_exception; | 75 | bool m_was_exception; //< Stores indicator of exception | ||
44 | }; | 76 | }; |