1 /** 2 * UGENE - Integrated Bioinformatics Tools. 3 * Copyright (C) 2008-2021 UniPro <ugene@unipro.ru> 4 * http://ugene.net 5 * 6 * This program is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU General Public License 8 * as published by the Free Software Foundation; either version 2 9 * of the License, or (at your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 19 * MA 02110-1301, USA. 20 */ 21 22 #ifndef _U2_SCRIPT_WORKER_H_ 23 #define _U2_SCRIPT_WORKER_H_ 24 25 #include <U2Lang/LocalDomain.h> 26 #include <U2Lang/WorkflowScriptEngine.h> 27 #include <U2Lang/WorkflowUtils.h> 28 29 namespace U2 { 30 31 namespace LocalWorkflow { 32 33 class ScriptWorkerTask : public Task { 34 Q_OBJECT 35 public: 36 ScriptWorkerTask(WorkflowScriptEngine *engine, AttributeScript *script); 37 void run(); 38 QVariant getResult() const; 39 WorkflowScriptEngine *getEngine(); 40 41 private: 42 QVariant result; 43 WorkflowScriptEngine *engine; 44 AttributeScript *script; 45 }; 46 47 class ScriptPromter : public PrompterBase<ScriptPromter> { 48 Q_OBJECT 49 public: 50 ScriptPromter(Actor *p = 0) 51 : PrompterBase<ScriptPromter>(p) { 52 } 53 54 protected: 55 QString composeRichDoc(); 56 }; 57 58 class ScriptWorker : public BaseWorker { 59 Q_OBJECT 60 public: 61 ScriptWorker(Actor *a); 62 virtual void init(); 63 virtual Task *tick(); 64 virtual void cleanup(); 65 virtual void setDone(); 66 67 private slots: 68 void sl_taskFinished(); 69 70 private: 71 void bindAttributeVariables(); 72 void bindPortVariables(); 73 74 CommunicationChannel *input; 75 CommunicationChannel *output; 76 WorkflowScriptEngine *engine; 77 AttributeScript *script; 78 bool taskFinished; 79 80 private: 81 bool isNeedToBeDone() const; 82 bool isNeedToBeRun() const; 83 }; 84 85 class ScriptWorkerFactory : public DomainFactory { 86 public: ScriptWorkerFactory(QString name)87 ScriptWorkerFactory(QString name) 88 : DomainFactory(name) { 89 } 90 91 virtual Worker *createWorker(Actor *a); 92 93 static bool init(QList<DataTypePtr> input, QList<DataTypePtr> output, QList<Attribute *> attrs, const QString &name, const QString &description, const QString &actorFilePath); 94 95 public: 96 static const QString ACTOR_ID; 97 }; 98 99 } // namespace LocalWorkflow 100 } // namespace U2 101 102 #endif 103