-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathtask.h
78 lines (58 loc) · 1.38 KB
/
task.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/*
* task.h
*
* Created on: Jan 10, 2014
* Author: baj
*/
#ifndef TASK_H_
#define TASK_H_
#include <string>
#include <iostream>
#include "logger.h"
#include "intention.h"
#include "simulator.h"
#include "tracker.h"
#include "gvector.h"
class HumanTracker;
class Task;
class TaskFactory
{
private:
TaskFactory();
virtual ~TaskFactory();
public:
typedef shared_ptr<Task> (*TaskCreator)();
static TaskFactory &ins();
bool Register(const std::string &name, TaskCreator creator);
shared_ptr<Task> CreateTask(const std::string &name);
void PrintTasks(std::ostream &os);
private:
HashMap<std::string, TaskCreator> mTaskMap;
};
class Task
{
public:
Task(std::string name);
virtual ~Task();
std::string &GetName() {
return mName;
}
HumanTracker *GetTracker() {
return mTracker;
}
virtual void Setup(HumanTracker *tracker);
virtual void RegisterIntentions() = 0;
virtual vector2d NewHumanPosition() = 0;
virtual shared_ptr<Simulator> CreateSimulator() = 0;
void SimulationTest(int argc, char **argv);
template <class TaskDerived >
static shared_ptr<Task> Creator() { return make_shared<TaskDerived>(); }
template <class TaskDerived>
static bool Register(const std::string &name) {
return TaskFactory::ins().Register(name, Creator<TaskDerived>);
}
private:
std::string mName;
HumanTracker *mTracker;
};
#endif /* TASK_H_ */