]> git.tdb.fi Git - builder.git/blobdiff - source/copy.h
Refactor InternalTask to take a functor
[builder.git] / source / copy.h
index 283ef48c5bbfa444b3f52a115562b041d1ca3cb3..c0a433996a9c0a14625ebf918c9c6092eac6d9e0 100644 (file)
@@ -1,35 +1,23 @@
 #ifndef COPY_H_
 #define COPY_H_
 
-#include <msp/core/thread.h>
-#include <msp/path/path.h>
-#include "action.h"
+#include "tool.h"
 
-class Package;
+class InstalledFile;
 
-class Copy: public Action
+/**
+Copies a file to another place.  Used by the InstalledFile target.
+*/
+class Copy: public Tool
 {
 public:
-       Copy(Builder &, const Package &, const Msp::Path::Path &, const Msp::Path::Path &);
-       int check();
-private:
-       class Worker: public Msp::Thread
-       {
-       public:
-               Worker(Copy &i): copy(i), done(false) { launch(); }
-               bool get_done() const { return done; }
-               bool get_error() const { return error; }
-       private:
-               Copy &copy;
-               bool done;
-               bool error;
+       Copy(Builder &b): Tool(b, "CP") { }
 
-               void main();
-       };
+       Target *create_target(const std::vector<Target *> &, const std::string &) override;
+       Task *run(const Target &) const override;
 
-       Msp::Path::Path src;
-       Msp::Path::Path dest;
-       Worker worker;
+private:
+       static bool _run(const InstalledFile &);
 };
 
 #endif