Changeset View
Changeset View
Standalone View
Standalone View
src/lib/session.h
Show All 34 Lines | |||||
35 | * Namespace collecting all Classes of the Cantor Libraries | 35 | * Namespace collecting all Classes of the Cantor Libraries | ||
36 | */ | 36 | */ | ||
37 | namespace Cantor | 37 | namespace Cantor | ||
38 | { | 38 | { | ||
39 | class Backend; | 39 | class Backend; | ||
40 | class SessionPrivate; | 40 | class SessionPrivate; | ||
41 | class CompletionObject; | 41 | class CompletionObject; | ||
42 | class SyntaxHelpObject; | 42 | class SyntaxHelpObject; | ||
43 | class DefaultVariableModel; | ||||
43 | 44 | | |||
44 | /** | 45 | /** | ||
45 | * The Session object is the main class used to interact with a Backend. | 46 | * The Session object is the main class used to interact with a Backend. | ||
46 | * It is used to evaluate Expressions, get completions, syntax highlighting, etc. | 47 | * It is used to evaluate Expressions, get completions, syntax highlighting, etc. | ||
47 | * | 48 | * | ||
48 | * @author Alexander Rieder | 49 | * @author Alexander Rieder | ||
49 | */ | 50 | */ | ||
50 | class CANTOR_EXPORT Session : public QObject | 51 | class CANTOR_EXPORT Session : public QObject | ||
51 | { | 52 | { | ||
52 | Q_OBJECT | 53 | Q_OBJECT | ||
53 | public: | 54 | public: | ||
54 | enum Status { | 55 | enum Status { | ||
55 | Running, ///< the session is busy, running some expression | 56 | Running, ///< the session is busy, running some expression | ||
56 | Done, ///< the session has done all the jobs, and is now waiting for more | 57 | Done, ///< the session has done all the jobs, and is now waiting for more | ||
57 | Disable ///< the session don't login yet, or already logout | 58 | Disable ///< the session don't login yet, or already logout | ||
58 | }; | 59 | }; | ||
59 | 60 | | |||
60 | /** | 61 | /** | ||
61 | * Create a new Session. This should not yet set up the complete session, | 62 | * Create a new Session. This should not yet set up the complete session, | ||
62 | * thats job of the login() function | 63 | * thats job of the login() function | ||
63 | * @see login() | 64 | * @see login() | ||
64 | */ | 65 | */ | ||
65 | explicit Session( Backend* backend); | 66 | explicit Session( Backend* backend); | ||
67 | | ||||
68 | /** | ||||
69 | * Similar to Session::Session, but also specify variable model for automatically handles model's updates | ||||
70 | */ | ||||
71 | explicit Session( Backend* backend, DefaultVariableModel* model); | ||||
72 | | ||||
66 | /** | 73 | /** | ||
67 | * Destructor | 74 | * Destructor | ||
68 | */ | 75 | */ | ||
69 | ~Session() override; | 76 | ~Session() override; | ||
70 | 77 | | |||
71 | /** | 78 | /** | ||
72 | * Login to the Session. In this function you should do anything needed to set up | 79 | * Login to the Session. In this function you should do anything needed to set up | ||
73 | * the session, and make it ready for usage. The method should be implemented non-blocking. | 80 | * the session, and make it ready for usage. The method should be implemented non-blocking. | ||
▲ Show 20 Lines • Show All 129 Lines • ▼ Show 20 Line(s) | 195 | protected: | |||
203 | 210 | | |||
204 | /** | 211 | /** | ||
205 | * Execute first expression in expression queue. | 212 | * Execute first expression in expression queue. | ||
206 | * Also, this function changes the status from Queued to Computing. | 213 | * Also, this function changes the status from Queued to Computing. | ||
207 | * @see expressionQueue() const | 214 | * @see expressionQueue() const | ||
208 | */ | 215 | */ | ||
209 | virtual void runFirstExpression(); | 216 | virtual void runFirstExpression(); | ||
210 | 217 | | |||
218 | /** | ||||
219 | * Opposite action to Session::runFirstExpression() | ||||
220 | * This method dequeue the expression and go to next expression, if queue not empty | ||||
221 | * Also, this method updates variableModel, if needed | ||||
222 | * If queue empty, session change status to Done | ||||
223 | */ | ||||
224 | virtual void finishFirstExpression(); | ||||
225 | | ||||
226 | /** | ||||
227 | * Starts variable update immideatly, usefull for subclasses, which run internal command | ||||
228 | * which could change variables listen | ||||
229 | */ | ||||
230 | virtual void forceVariableUpdate(); | ||||
asemke: updateVariables() is shorter and sounds better. | |||||
231 | | ||||
211 | Q_SIGNALS: | 232 | Q_SIGNALS: | ||
212 | void statusChanged(Cantor::Session::Status newStatus); | 233 | void statusChanged(Cantor::Session::Status newStatus); | ||
213 | void loginStarted(); | 234 | void loginStarted(); | ||
214 | void loginDone(); | 235 | void loginDone(); | ||
215 | void error(const QString& msg); | 236 | void error(const QString& msg); | ||
216 | 237 | | |||
217 | private: | 238 | private: | ||
218 | SessionPrivate* d; | 239 | SessionPrivate* d; | ||
219 | }; | 240 | }; | ||
220 | } | 241 | } | ||
221 | #endif /* _SESSION_H */ | 242 | #endif /* _SESSION_H */ |
updateVariables() is shorter and sounds better.