Files
checker_host/interface/interface.h

48 lines
919 B
C
Raw Normal View History

2023-11-21 20:28:23 +08:00
#ifndef INTERFACE_H
#define INTERFACE_H
#include <QObject>
#include "base/base.h"
2023-11-26 23:05:35 +08:00
#include "interface/codec.h"
2023-11-21 20:28:23 +08:00
using namespace std;
using namespace std::placeholders;
2023-11-26 23:05:35 +08:00
typedef std::function<void(myarray data)> irq_cb;
2023-11-21 20:28:23 +08:00
class InterFace : public QObject
{
Q_OBJECT
public:
2023-11-26 23:05:35 +08:00
InterFace() {irq_fun=nullptr;}
2023-11-21 20:28:23 +08:00
virtual ~InterFace() {}
virtual void init() = 0;
virtual int write(myarray data) = 0;
2023-11-26 23:05:35 +08:00
virtual void set_irq(irq_cb fun){
this->irq_fun=fun;
}
protected:
irq_cb irq_fun;
2023-11-21 20:28:23 +08:00
};
InterFace *interFaceFind(const char *name);
2023-11-26 23:05:35 +08:00
typedef struct{
const char *name;
InterFace *(*if_get_fun)();
}if_def;
#define if_export(name_,fun_) \
const static char __if_##name_##_name[] __attribute__((section(".rodata.ifstr"))) = #name_; \
__attribute__((used)) static if_def _if_##name_ __attribute__((section("ifdef")))={\
.name=__if_##name_##_name,\
.if_get_fun=fun_,\
}
2023-11-21 20:28:23 +08:00
#endif // INTERFACE_H