diff options
| author | Simon Robertshaw <simon@hardwired.org.uk> | 2012-11-17 19:44:09 (GMT) |
|---|---|---|
| committer | Simon Robertshaw <simon@hardwired.org.uk> | 2012-11-17 19:44:09 (GMT) |
| commit | 058a2edd75debbd0297f92572316daa704bd379f (patch) | |
| tree | ad303f091f9a08b209b91eb34a9fcad996a3de69 /src/tasks/Task.h | |
| parent | e3594aba9e05c6865d396418c028049cda92c2f3 (diff) | |
| parent | 7a21ae192fe19868539956f3fe28e62b2c7c4429 (diff) | |
| download | powder-058a2edd75debbd0297f92572316daa704bd379f.zip powder-058a2edd75debbd0297f92572316daa704bd379f.tar.gz | |
Merge branch 'master' of github.com:FacialTurd/PowderToypp
Diffstat (limited to 'src/tasks/Task.h')
| -rw-r--r-- | src/tasks/Task.h | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/src/tasks/Task.h b/src/tasks/Task.h new file mode 100644 index 0000000..a025ac1 --- /dev/null +++ b/src/tasks/Task.h @@ -0,0 +1,63 @@ +/* + * Task.h + * + * Created on: Apr 6, 2012 + * Author: Simon + */ + +#ifndef TASK_H_ +#define TASK_H_ + +#include <string> +#include <pthread.h> +#undef GetUserName //God dammit microsoft! +#include "TaskListener.h" + +class TaskListener; +class Task { +public: + void AddTaskListener(TaskListener * listener); + void Start(); + int GetProgress(); + bool GetDone(); + bool GetSuccess(); + std::string GetError(); + std::string GetStatus(); + void Poll(); + Task() : listener(NULL) { progress = 0; } + virtual ~Task(); +protected: + int progress; + bool done; + bool success; + std::string status; + std::string error; + + int thProgress; + bool thDone; + bool thSuccess; + std::string thStatus; + std::string thError; + + TaskListener * listener; + pthread_t doWorkThread; + pthread_mutex_t taskMutex; + pthread_cond_t taskCond; + + + virtual void before(); + virtual void after(); + virtual bool doWork(); + static void * doWork_helper(void * ref); + + virtual void notifyProgress(int progress); + virtual void notifyError(std::string error); + virtual void notifyStatus(std::string status); + + virtual void notifyProgressMain(); + virtual void notifyErrorMain(); + virtual void notifyStatusMain(); + virtual void notifyDoneMain(); +}; + +#endif /* TASK_H_ */ |
