Firmware updater: Perform work in a background thread
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
#ifndef slic3r_avrdude_slic3r_hpp_
|
||||
#define slic3r_avrdude_slic3r_hpp_
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <ostream>
|
||||
#include <functional>
|
||||
|
||||
namespace Slic3r {
|
||||
@@ -11,11 +11,13 @@ namespace Slic3r {
|
||||
class AvrDude
|
||||
{
|
||||
public:
|
||||
typedef std::shared_ptr<AvrDude> Ptr;
|
||||
typedef std::function<void(const char * /* msg */, unsigned /* size */)> MessageFn;
|
||||
typedef std::function<void(const char * /* task */, unsigned /* progress */)> ProgressFn;
|
||||
typedef std::function<void(int /* exit status */)> CompleteFn;
|
||||
|
||||
AvrDude();
|
||||
AvrDude(AvrDude &&) = delete;
|
||||
AvrDude(AvrDude &&) = default;
|
||||
AvrDude(const AvrDude &) = delete;
|
||||
AvrDude &operator=(AvrDude &&) = delete;
|
||||
AvrDude &operator=(const AvrDude &) = delete;
|
||||
@@ -23,17 +25,26 @@ public:
|
||||
|
||||
// Set location of avrdude's main configuration file
|
||||
AvrDude& sys_config(std::string sys_config);
|
||||
|
||||
// Set avrdude cli arguments
|
||||
AvrDude& args(std::vector<std::string> args);
|
||||
|
||||
// Set message output callback
|
||||
AvrDude& on_message(MessageFn fn);
|
||||
|
||||
// Set progress report callback
|
||||
// Progress is reported per each task (reading / writing), progress is reported in percents.
|
||||
AvrDude& on_progress(MessageFn fn);
|
||||
|
||||
int run(std::vector<std::string> args);
|
||||
|
||||
// Called when avrdude's main function finishes
|
||||
AvrDude& on_complete(CompleteFn fn);
|
||||
|
||||
int run_sync();
|
||||
Ptr run();
|
||||
void join();
|
||||
private:
|
||||
std::string m_sys_config;
|
||||
MessageFn m_message_fn;
|
||||
ProgressFn m_progress_fn;
|
||||
struct priv;
|
||||
std::unique_ptr<priv> p;
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user