Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 #ifndef _DB_TASK_H_
00036 #define _DB_TASK_H_
00037
00038 #include <iostream>
00039
00040 #include "DBPlanner/task.h"
00041
00042 namespace db_planner {
00043 class DatabaseManager;
00044 }
00045
00046 namespace graspit_dbase_tasks {
00047
00048 class DBTaskDispatcher;
00049
00051
00079 class DBTask {
00080 public:
00081 enum Status{RUNNING, ERROR, DONE};
00082 protected:
00084 Status mStatus;
00085
00087 DBTaskDispatcher* mDispatcher;
00088
00090
00091 db_planner::DatabaseManager *mDBMgr;
00092
00094 db_planner::TaskRecord mRecord;
00095
00096 public:
00097 DBTask(DBTaskDispatcher *disp, db_planner::DatabaseManager *mgr, db_planner::TaskRecord rec)
00098 : mDispatcher(disp), mDBMgr(mgr), mRecord(rec) {};
00099
00100 virtual ~DBTask(){}
00101
00102 virtual void start() = 0;
00103
00104 virtual void mainLoop() {}
00105
00107 Status getStatus(){return mStatus;}
00108
00110 db_planner::TaskRecord getRecord(){return mRecord;}
00111 };
00112
00114
00116 class DBEmptyTask : public DBTask
00117 {
00118 public:
00119 DBEmptyTask(DBTaskDispatcher *disp, db_planner::DatabaseManager *mgr, db_planner::TaskRecord rec) :
00120 DBTask(disp, mgr, rec) {}
00121 ~DBEmptyTask(){}
00122 void start(){std::cout << "Started simple task\n"; mStatus = RUNNING;}
00123 void mainLoop(){std::cout << "Finished simple task\n"; mStatus = DONE;}
00124 };
00125
00127
00129 class DBEmptyOneShotTask : public DBTask
00130 {
00131 public:
00132 DBEmptyOneShotTask(DBTaskDispatcher *disp, db_planner::DatabaseManager *mgr, db_planner::TaskRecord rec) :
00133 DBTask(disp, mgr, rec) {}
00134 ~DBEmptyOneShotTask(){}
00135 void start(){std::cout << "Started and finished one-shot simple task\n"; mStatus = DONE;}
00136 };
00137
00138 }
00139
00140 #endif