work_queue.cpp
Go to the documentation of this file.
00001 #include <pcl/apps/cloud_composer/qt.h>
00002 #include <pcl/apps/cloud_composer/work_queue.h>
00003 #include <pcl/apps/cloud_composer/tool_interface/abstract_tool.h>
00004 
00005 pcl::cloud_composer::WorkQueue::WorkQueue (QObject* parent)
00006   : QObject (parent)
00007 {
00008     
00009     
00010     
00011 }
00012 
00013 
00014 pcl::cloud_composer::WorkQueue::~WorkQueue ( )
00015 {
00016   
00017   
00018 }
00019 
00020 void
00021 pcl::cloud_composer::WorkQueue::enqueueNewAction (AbstractTool* new_tool, ConstItemList input_data)
00022 {
00023   ActionPair new_action;
00024   //Create a command which will manage data for the tool
00025   new_action.command = new_tool->createCommand (input_data);
00026   new_action.tool = new_tool;
00027  
00028   work_queue_.enqueue (new_action);
00029   checkQueue ();
00030 }
00031 
00032 void
00033 pcl::cloud_composer::WorkQueue::actionFinished (ActionPair finished_action)
00034 {
00035   //Signal the project model that the command is done 
00036   emit commandComplete (finished_action.command);
00037   
00038   //Queue the tool for deletion
00039   finished_action.tool->deleteLater ();
00040   //Check if there are any remaining commands in queue
00041   checkQueue ();
00042   
00043 }
00044 
00045 void
00046 pcl::cloud_composer::WorkQueue::checkQueue ( )
00047 {
00048   if (work_queue_.length () > 0)
00049   {
00050     ActionPair action_to_execute = work_queue_.dequeue ();
00051     if (action_to_execute.command->runCommand (action_to_execute.tool))
00052     {
00053       //Success, send the command back to the main thread
00054       actionFinished (action_to_execute);
00055     }
00056     else
00057     {
00058       qDebug () << "FAILED TO EXECUTE COMMAND";
00059      //Failure, what to do with data?? 
00060     }
00061       
00062       
00063   }
00064     
00065   
00066 }


pcl
Author(s): Open Perception
autogenerated on Wed Aug 26 2015 15:38:43