2 * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 * @author Tomasz Iwanek (t.iwanek@samsung.com)
20 * @brief Implementation file for task list
23 #include <dpl/mutable_task_list.h>
24 #include <dpl/assert.h>
27 MutableTaskList::MutableTaskList() :
30 m_currentTask = m_tasks.end();
33 MutableTaskList::~MutableTaskList()
35 for (Tasks::iterator i = m_tasks.begin(); i != m_tasks.end(); ++i) {
40 void MutableTaskList::AddTask(Task *task)
44 m_tasks.push_back(task);
45 m_currentTask = m_tasks.begin();
49 m_tasks.push_back(task);
53 bool MutableTaskList::NextStep()
58 m_currentTask != m_tasks.end() &&
59 "Task list is empty or all tasks done");
61 bool result = (*m_currentTask)->NextStep();
67 return ++m_currentTask != m_tasks.end();
70 bool MutableTaskList::Abort()
72 m_tasks.erase(m_currentTask, m_tasks.end());
74 for (Tasks::iterator i = m_tasks.begin(); i != m_tasks.end();) {
75 //If given task does not have any "abortSteps", remove it from the list
84 if (m_tasks.empty()) {
88 m_currentTask = m_tasks.begin();
93 size_t MutableTaskList::GetStepCount() const
97 for (Tasks::const_iterator i = m_tasks.begin(); i != m_tasks.end(); ++i) {
98 count += (*i)->GetStepCount();