UGDK  0.4.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
generictask.h
Go to the documentation of this file.
1 #ifndef UGDK_ACTION_GENERICTASK_H_
2 #define UGDK_ACTION_GENERICTASK_H_
3 
4 #include <ugdk/portable/tr1.h>
5 #include FROM_TR1(functional)
6 #include <ugdk/action/task.h>
7 
8 namespace ugdk {
9 
10 namespace action {
11 
12 class GenericTask : public Task {
13  typedef Task super;
14  protected:
15  std::tr1::function<bool (double)> function_;
16  public:
17  GenericTask(std::tr1::function<bool (double)> func) : function_(func) {}
18 
19  GenericTask(std::tr1::function<bool (double)> func, int priority)
20  : Task(priority), function_(func) {}
21 
22  void operator()(double dt) {
23  finished_ = !function_(dt);
24  }
25 };
26 
27 } /* namespace action */
28 
29 } /* namespace ugdk */
30 
31 #endif /* UGDK_ACTION_GENERICTASK_H_ */