summaryrefslogtreecommitdiff
path: root/task.h
blob: 2dd05e35837f230edc74a60080b6e264f509ed47 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// -*- c++ -*-
#pragma once

#include <vector>
#include <string>
#include <atomic>
#include <list>
#include <memory>

class Task
{
public:
	Task(const std::vector<std::string>& depends);

	void registerDepTasks(const std::list<std::shared_ptr<Task>>& tasks);

	bool dirty();
	bool ready();
	int run();
	bool done() const;
	virtual int clean() = 0 ;
	virtual std::vector<std::string> depends() const = 0;
	virtual std::string target() const = 0;

protected:
	std::atomic<bool> is_done{false};
	virtual int runInner() { return 0; };
	virtual bool dirtyInner() { return false; }

	std::vector<std::string> dependsStr;
	std::list<std::shared_ptr<Task>> dependsTasks;
};