plugin prep
This commit is contained in:
parent
4cfefdd1ab
commit
5e8455c8a2
10
inc/graph/plugins/http/http.h
Normal file
10
inc/graph/plugins/http/http.h
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <graph/plugins/plugin.h>
|
||||||
|
|
||||||
|
extern "C" {
|
||||||
|
extern plugin_t plugin;
|
||||||
|
|
||||||
|
bool init();
|
||||||
|
void destroy();
|
||||||
|
}
|
@ -4,6 +4,7 @@
|
|||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#else
|
#else
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <stdbool.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -1,15 +1,29 @@
|
|||||||
|
#include <graph/plugins/http/http.h>
|
||||||
#include <graph/plugins/plugin.h>
|
#include <graph/plugins/plugin.h>
|
||||||
|
#include <cmath>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
#define PI 3.1415
|
||||||
|
#define to_rad(x) (x/180/3.1415)
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
||||||
|
plugin_t plugin = {.version = 1, .init_method = &init, .destroy_method = &destroy};
|
||||||
|
|
||||||
bool init() {
|
bool init() {
|
||||||
std::cout << "init" << std::endl;
|
std::cout << "init" << std::endl;
|
||||||
|
point_t points[100];
|
||||||
|
for (int i = 0; i < 100; i++) {
|
||||||
|
double deg = i*360/100.0;
|
||||||
|
points[i].x = deg;
|
||||||
|
points[i].y = sin(to_rad(deg));
|
||||||
|
}
|
||||||
|
|
||||||
|
plugin.update_callback(0, "1st", points);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void destroy() { std::cout << "destory" << std::endl; }
|
void destroy() {
|
||||||
|
std::cout << "destory" << std::endl;
|
||||||
plugin_t plugin = {
|
}
|
||||||
.version = 1, .init_method = &init, .destroy_method = &destroy};
|
|
||||||
}
|
}
|
@ -63,7 +63,9 @@ void MainWindow::on_action_Load_triggered() {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
pluginModel->add(new Plugin(file.toStdString()));
|
Plugin* plugin = new Plugin(file.toStdString());
|
||||||
|
// plugin->init(update_callback);
|
||||||
|
pluginModel->add(plugin);
|
||||||
} catch (std::runtime_error e) {
|
} catch (std::runtime_error e) {
|
||||||
std::cout << e.what() << std::endl;
|
std::cout << e.what() << std::endl;
|
||||||
QMessageBox::critical(this, "Error", "Failed to load plugin.", QMessageBox::StandardButton::Ignore);
|
QMessageBox::critical(this, "Error", "Failed to load plugin.", QMessageBox::StandardButton::Ignore);
|
||||||
|
@ -1,13 +1,7 @@
|
|||||||
#include <dlfcn.h>
|
|
||||||
#include <graph/server/gui/mainwindow.h>
|
#include <graph/server/gui/mainwindow.h>
|
||||||
#include <graph/server/plugin.h>
|
|
||||||
#include <QtWidgets/QApplication>
|
#include <QtWidgets/QApplication>
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
int main(int argc, char** argv) {
|
int main(int argc, char** argv) {
|
||||||
// Graph::Plugin plugin("plugins/libhttp.so");
|
|
||||||
// plugin.init((update_callback_t)1);
|
|
||||||
|
|
||||||
QApplication app(argc, argv);
|
QApplication app(argc, argv);
|
||||||
Graph::GUI::MainWindow window;
|
Graph::GUI::MainWindow window;
|
||||||
window.show();
|
window.show();
|
||||||
|
Loading…
Reference in New Issue
Block a user