Update the dispatcher class to return a pointer to the newly created DProcess object so that the requestor can connect to various process signals as needed.

This commit is contained in:
Ken Moore
2016-02-22 09:41:09 -05:00
parent 2bd77b9882
commit e8b65c04d2
2 changed files with 21 additions and 18 deletions

View File

@@ -109,27 +109,29 @@ void Dispatcher::stop(){
}
//Overloaded Main Calling Functions (single command, or multiple in-order commands)
void Dispatcher::queueProcess(QString ID, QString cmd){
queueProcess(NO_QUEUE, ID, QStringList() << cmd);
DProcess* Dispatcher::queueProcess(QString ID, QString cmd){
return queueProcess(NO_QUEUE, ID, QStringList() << cmd);
}
void Dispatcher::queueProcess(QString ID, QStringList cmds){
queueProcess(NO_QUEUE, ID, cmds);
DProcess* Dispatcher::queueProcess(QString ID, QStringList cmds){
return queueProcess(NO_QUEUE, ID, cmds);
}
void Dispatcher::queueProcess(Dispatcher::PROC_QUEUE queue, QString ID, QString cmd){
queueProcess(queue, ID, QStringList() << cmd);
DProcess* Dispatcher::queueProcess(Dispatcher::PROC_QUEUE queue, QString ID, QString cmd){
return queueProcess(queue, ID, QStringList() << cmd);
}
void Dispatcher::queueProcess(Dispatcher::PROC_QUEUE queue, QString ID, QStringList cmds){
DProcess* Dispatcher::queueProcess(Dispatcher::PROC_QUEUE queue, QString ID, QStringList cmds){
//This is the primary queueProcess() function - all the overloads end up here to do the actual work
//For multi-threading, need to emit a signal/slot for this action (object creations need to be in same thread as parent)
qDebug() << "Queue Process:" << queue << ID << cmds;
emit mkProcs(queue, ID, cmds);
DProcess *P = createProcess(ID, cmds);
emit mkProcs(queue, P);
return P;
}
// === PRIVATE ===
//Simplification routine for setting up a process
DProcess* Dispatcher::createProcess(QString ID, QStringList cmds){
DProcess* P = new DProcess();
P->moveToThread(this->thread());
DProcess *P = new DProcess();
//P->moveToThread(this->thread());
P->cmds = cmds;
P->ID = ID;
connect(P, SIGNAL(ProcFinished(QString)), this, SLOT(ProcFinished(QString)) );
@@ -137,9 +139,10 @@ DProcess* Dispatcher::createProcess(QString ID, QStringList cmds){
}
// === PRIVATE SLOTS ===
void Dispatcher::mkProcs(Dispatcher::PROC_QUEUE queue, QString ID, QStringList cmds){
void Dispatcher::mkProcs(Dispatcher::PROC_QUEUE queue, DProcess *P){
//qDebug() << " - Create Process:" << queue << ID << cmds;
DProcess *P = createProcess(ID, cmds);
//DProcess *P = createProcess(ID, cmds);
P->moveToThread(this->thread());
QList<DProcess*> list;
if(!HASH.contains(queue)){ HASH.insert(queue, list); } //insert an empty list
HASH[queue] << P; //add this proc to the end of the list

View File

@@ -61,10 +61,10 @@ public slots:
void stop(); //save any currently-unrun processes for next time
//Main Calling Functions (single command, or multiple in-order commands)
void queueProcess(QString ID, QString cmd); //uses NO_QUEUE
void queueProcess(QString ID, QStringList cmds); //uses NO_QUEUE
void queueProcess(Dispatcher::PROC_QUEUE, QString ID, QString cmd);
void queueProcess(Dispatcher::PROC_QUEUE, QString ID, QStringList cmds);
DProcess* queueProcess(QString ID, QString cmd); //uses NO_QUEUE
DProcess* queueProcess(QString ID, QStringList cmds); //uses NO_QUEUE
DProcess* queueProcess(Dispatcher::PROC_QUEUE, QString ID, QString cmd);
DProcess* queueProcess(Dispatcher::PROC_QUEUE, QString ID, QStringList cmds);
private:
// Queue file
@@ -77,7 +77,7 @@ private:
DProcess* createProcess(QString ID, QStringList cmds);
private slots:
void mkProcs(Dispatcher::PROC_QUEUE, QString ID, QStringList cmds);
void mkProcs(Dispatcher::PROC_QUEUE, DProcess *P);
void ProcFinished(QString ID);
void CheckQueues();
@@ -87,7 +87,7 @@ signals:
void DispatchStarting(QString ID);
//Signals for private usage
void mkprocs(Dispatcher::PROC_QUEUE, QString ID, QStringList cmds);
void mkprocs(Dispatcher::PROC_QUEUE, DProcess*);
};