83 lines
1.9 KiB
C++
83 lines
1.9 KiB
C++
#ifndef WORK_LIST_H_INCLUDED
|
|
#define WORK_LIST_H_INCLUDED
|
|
|
|
#include <vector>
|
|
#include <memory>
|
|
|
|
class UpdateCommand;
|
|
|
|
|
|
/**
|
|
* @brief This class is responsible for calling the several binaries
|
|
* \ref ATBUpdateTool consists of.
|
|
*
|
|
* This class maintains a worklist, which conists of entries of type UpdateCommand.
|
|
*
|
|
* @see UpdateCommand
|
|
*/
|
|
class WorkList {
|
|
/**
|
|
* @brief Actual worklist of items to be eecuted.
|
|
*/
|
|
std::vector<std::unique_ptr<UpdateCommand>> m_workList;
|
|
public:
|
|
unsigned m_workListIndex{0};
|
|
|
|
WorkList() = default;
|
|
|
|
/**
|
|
* \brief Put new work item into worklist.
|
|
*
|
|
* \tparam arg Work item to be added to worklist.
|
|
*/
|
|
template<typename T>
|
|
void push_back(T&& arg) {
|
|
m_workList.push_back(std::forward<T>(arg));
|
|
}
|
|
|
|
/**
|
|
* \brief Check if worklist is empty.
|
|
*
|
|
* \retval true if worklist is empty.
|
|
* \retval false otherwise.
|
|
*/
|
|
bool empty() const { return m_workList.empty(); }
|
|
|
|
// move constructor: pass in classes derived from UpdateCommand
|
|
// template<typename... Ts>
|
|
//typename = typename std::enable_if<std::is_same<typename std::decay<Ts...>::type,
|
|
// UpdateCommand>::value>::type>
|
|
// WorkList(Ts&&... args)
|
|
// : m_workList(std::forward<Ts...>(args...))
|
|
// , m_workListIndex(0) {
|
|
//}
|
|
|
|
///**
|
|
// * \brief Put new work item into worklist.
|
|
// *
|
|
// */
|
|
//unsigned nextExecIndex() const;
|
|
|
|
/**
|
|
* \brief Put new work item into worklist.
|
|
*
|
|
*/
|
|
bool nextExec() const;
|
|
|
|
/**
|
|
* \brief Put new work item into worklist.
|
|
*
|
|
* \param last
|
|
*/
|
|
bool exec(bool last=false);
|
|
|
|
/**
|
|
* \brief Get current size of worklist.
|
|
*
|
|
* \retval Current size of worklist.
|
|
*/
|
|
unsigned size() { return m_workList.size(); }
|
|
};
|
|
|
|
#endif // WORK_LIST_H_INCLUDED
|