Eris
1.3.19
|
00001 #ifndef ERIS_TASK_H 00002 #define ERIS_TASK_H 00003 00004 #include <sigc++/trackable.h> 00005 #include <sigc++/signal.h> 00006 00007 #include <map> 00008 #include <string> 00009 00010 namespace Atlas { 00011 namespace Message { 00012 class Element; 00013 typedef std::map<std::string, Element> MapType; 00014 } 00015 } 00016 00017 namespace WFMath { class TimeDiff; } 00018 00019 namespace Eris 00020 { 00021 00022 class Entity; 00023 class View; 00024 00025 class Task : public sigc::trackable 00026 { 00027 public: 00028 virtual ~Task(); 00029 00034 const std::string& name() const; 00035 00040 double progress() const; 00041 00046 bool isComplete() const; 00047 00048 sigc::signal<void> Completed; 00049 00050 sigc::signal<void> Cancelled; 00051 00052 sigc::signal<void> Progressed; 00053 00054 sigc::signal<void> ProgressRateChanged; 00055 00056 private: 00057 void progressChanged(); 00058 00059 friend class View; // so it can call updateProgress 00060 friend class Entity; // for constructor and updateFromAtlas 00061 00065 Task(Entity* owner, const std::string& nm); 00066 00067 void updateFromAtlas(const Atlas::Message::MapType& d); 00068 00072 void updatePredictedProgress(const WFMath::TimeDiff& dt); 00073 00074 const std::string m_name; 00075 Entity* m_owner; 00076 double m_progress; 00077 00079 double m_progressRate; 00080 }; 00081 00082 inline const std::string& Task::name() const 00083 { 00084 return m_name; 00085 } 00086 00087 inline double Task::progress() const 00088 { 00089 return m_progress; 00090 } 00091 00092 00093 } 00094 00095 #endif