#pragma once
#include "TDengineSubscriber_global.h"
#include "Publisher.h"
#include "TDengineClient.h"
#include <QQueue>
#include <QMutex>
#include <QWaitCondition>
struct Msg{
    QString key;
    QString val;
};
class TDENGINESUBSCRIBER_EXPORT TDengineSubscriber : public Publisher
{
    Q_OBJECT
public:
    TDengineSubscriber();
    ~TDengineSubscriber();
    // virtual void shares(SharedData * share);
    virtual void Run(const ModuleInfo& mi);
    virtual void setLoader(QLibrary*);
    void enqueue(const QString& key,const QString& val);
protected:
    virtual void run();
signals:
    void pubData(const QString& ,const QString& ,const QVariant&);
private:
    TDengineClient* tdengine = nullptr;
    QMutex mutex;
    QWaitCondition cond;
    QQueue<Msg> msgQueue;
};


extern "C" {//一定要添加上
TDENGINESUBSCRIBER_EXPORT Publisher* instance();
TDENGINESUBSCRIBER_EXPORT void destroy(Publisher*);
}
