cutter/src/common/RizinTask.h

62 lines
1.0 KiB
C
Raw Normal View History

2018-07-22 13:04:13 +00:00
#ifndef RZTASK_H
#define RZTASK_H
2018-07-22 13:04:13 +00:00
#include "core/Cutter.h"
2018-07-22 13:04:13 +00:00
2021-01-24 14:50:13 +00:00
class CUTTER_EXPORT RizinTask : public QObject
2018-07-22 13:04:13 +00:00
{
Q_OBJECT
protected:
2020-10-28 12:28:04 +00:00
RzCoreTask *task;
2018-07-22 13:04:13 +00:00
RizinTask() {}
2018-07-22 13:04:13 +00:00
void taskFinished();
public:
2020-12-16 09:51:53 +00:00
using Ptr = QSharedPointer<RizinTask>;
virtual ~RizinTask();
2018-07-22 13:04:13 +00:00
void startTask();
void breakTask();
void joinTask();
signals:
void finished();
};
2021-01-24 14:50:13 +00:00
class CUTTER_EXPORT RizinCmdTask : public RizinTask
{
Q_OBJECT
private:
static void taskFinishedCallback(const char *, void *user);
public:
explicit RizinCmdTask(const QString &cmd, bool transient = true);
2018-07-22 13:04:13 +00:00
QString getResult();
QJsonDocument getResultJson();
2018-07-22 13:04:13 +00:00
const char *getResultRaw();
};
2018-07-22 13:04:13 +00:00
2021-01-24 14:50:13 +00:00
class CUTTER_EXPORT RizinFunctionTask : public RizinTask
{
Q_OBJECT
private:
std::function<void *(RzCore *)> fcn;
void *res;
static void *runner(RzCore *core, void *user);
public:
explicit RizinFunctionTask(std::function<void *(RzCore *)> fcn, bool transient = true);
void *getResult() { return res; }
2018-07-22 13:04:13 +00:00
};
#endif // RZTASK_H