35 m_viewers.insert(std::map<int, AbstractProgressViewer*>::value_type(
id, apv));
38 std::map<int, TaskProgress*>::iterator it =
m_tasks.begin();
42 apv->
addTask(it->second, it->first);
51 std::map<int, AbstractProgressViewer*>::iterator it = m_viewers.find(viewerId);
53 if(it != m_viewers.end())
63 int id = generateTaskId();
65 m_tasks.insert(std::map<int, TaskProgress*>::value_type(
id, tp));
68 std::map<int, AbstractProgressViewer*>::iterator itV = m_viewers.begin();
70 while(itV != m_viewers.end())
72 itV->second->addTask(tp,
id);
84 std::map<int, TaskProgress*>::iterator it = m_tasks.find(taskId);
86 if(it != m_tasks.end())
89 std::map<int, AbstractProgressViewer*>::iterator itV = m_viewers.begin();
91 while(itV != m_viewers.end())
93 itV->second->removeTask(taskId);
104 std::map<int, TaskProgress*>::iterator it = m_tasks.find(taskId);
106 if(it != m_tasks.end())
109 std::map<int, AbstractProgressViewer*>::iterator itV = m_viewers.begin();
111 while(itV != m_viewers.end())
113 itV->second->cancelTask(taskId);
124 std::vector<TaskProgress*> cancelled;
125 std::map<int, TaskProgress*>::iterator it = m_tasks.begin();
127 while(it != m_tasks.end())
129 if(it->second->getType() == type)
130 cancelled.push_back(it->second);
135 for(std::size_t i = 0; i < cancelled.size(); ++i)
136 cancelled[i]->cancel();
141 std::map<int, AbstractProgressViewer*>::iterator itV = m_viewers.begin();
143 while(itV != m_viewers.end())
145 itV->second->setTotalValues(taskId);
153 std::map<int, AbstractProgressViewer*>::iterator itV = m_viewers.begin();
155 while(itV != m_viewers.end())
157 itV->second->updateValue(taskId);
165 std::map<int, AbstractProgressViewer*>::iterator itV = m_viewers.begin();
167 while(itV != m_viewers.end())
169 itV->second->updateMessage(taskId);
194 return m_viewerCounter++;
199 return m_taskCounter++;
This class can be used to inform the progress of a task.
A singleton class used to manage tasks progresses and their viewers.
int addTask(TaskProgress *tp)
Used in TaskProgress constructor, register this task generating a task id.
std::map< int, TaskProgress * > m_tasks
Container with tasks.
This class can be used to inform the progress of a task.
virtual void addTask(TaskProgress *t, int id)=0
Insert a new task in the progress viewer.
void cancelTask(int taskId)
Inform all viewers that a task was canceled.
int generateTaskId()
Used to generate a new task id (use internal counter).
A class that defines the interface of an abstract progress viewer.
void removeViewer(int viewerId)
Dettach a progress viewer.
A class that defines the interface of an abstract progress viewer.
void setTotalValues(int taskId)
Inform all viewers that a task set the total values.
void cancelTasks(unsigned int type)
Cancels the task with the given task type and inform all viewers that a task was canceled.
ObjectLevelLockingPolicy< ::boost::lock_guard< ::boost::recursive_mutex > > LockWrite
void removeTask(int taskId)
Used in TaskProgress destructor, remove task from singleton.
~ProgressManager()
Destructor.
std::map< int, AbstractProgressViewer * > m_viewers
Container with viewers.
int addViewer(AbstractProgressViewer *apv)
Attach a progress viewer.
ProgressManager()
Default constructor.
void updateMessage(int taskId)
Inform all viewers that a task set the message.
void clearAll()
Removes references for Viewers and tasks.
int generateViewerId()
Used to generate a new viewer id (use internal counter).
void updateValue(int taskId)
Inform all viewers that a task set the current step.