eris  1.4.0
A WorldForge client library.
Task.h
1 #ifndef ERIS_TASK_H
2 #define ERIS_TASK_H
3 
4 #include <sigc++/trackable.h>
5 #include <sigc++/signal.h>
6 
7 #include <map>
8 #include <string>
9 #include <vector>
10 #include "Usage.h"
11 
12 namespace Atlas {
13 namespace Message {
14 class Element;
15 
16 typedef std::map<std::string, Element> MapType;
17 }
18 }
19 
20 namespace WFMath { class TimeDiff; }
21 
22 namespace Eris {
23 
24 class Entity;
25 
26 class View;
27 
28 class Task : public sigc::trackable {
29 public:
33  Task(Entity& owner, std::string name);
34 
35  virtual ~Task();
36 
41  const std::string& name() const;
42 
47  double progress() const;
48 
53  double progressRate() const;
54 
59  bool isComplete() const;
60 
61  const std::vector<TaskUsage>& getUsages() const;
62 
63  sigc::signal<void> Completed;
64 
65  sigc::signal<void> Progressed;
66 
67  sigc::signal<void> ProgressRateChanged;
68 
69  sigc::signal<void> UsagesChanged;
70 
71 private:
72  void progressChanged();
73 
74  friend class View; // so it can call updateProgress
75  friend class Entity; // for constructor and updateFromAtlas
76 
77  void updateFromAtlas(const Atlas::Message::MapType& d);
78 
82  void updatePredictedProgress(const WFMath::TimeDiff& dt);
83 
84  const std::string m_name;
85  Entity& m_owner;
86  double m_progress;
87 
89  double m_progressRate;
90 
91  std::vector<TaskUsage> m_usages;
92 };
93 
94 inline const std::string& Task::name() const {
95  return m_name;
96 }
97 
98 inline double Task::progress() const {
99  return m_progress;
100 }
101 
102 inline double Task::progressRate() const {
103  return m_progressRate;
104 }
105 
106 
107 inline const std::vector<TaskUsage>& Task::getUsages() const {
108  return m_usages;
109 }
110 }
111 
112 #endif
Definition: Task.h:20
Definition: Account.cpp:33
Entity is a concrete (instantiable) class representing one game entity.
Definition: Entity.h:55