
//
// Created by Ht on 2022/8/28.
//

#ifndef INC_1_LIBDEVCPP_QGACYPHERPLUGINENTRY_H
#define INC_1_LIBDEVCPP_QGACYPHERPLUGINENTRY_H

#include <qlibc/qlibc.h>
#include <qlibc/plugin/QPluginEntry.h>
#include <qlibc/ByteUtils.h>
#include <jedp/JEDPAnalyzer.h>

#include <src/vdao/QGAPortPool.h>

namespace jedge {

    /**
     * 处理加密函数的插件：
     *      获得 mqtt加密、 mqtt解密、 登录加密等函数的入口，并可获得一些额外的标准函数接口。
     */

    class JE_API QGaSerialRebufferPluginEntry :
        public qlibc::QPluginEntry {
    protected:
        std::string sn_;
        QGAPortPool* pool_;

        JEDPRAnalyzer  analyzer_ = nullptr;

    public:
        explicit QGaSerialRebufferPluginEntry(std::string name, std::string type = "cypher", int ver = 0) :
                qlibc::QPluginEntry(std::move(name), std::move(type), ver) {
        }

        ~QGaSerialRebufferPluginEntry() override {}

        virtual std::shared_ptr<QGaSerialRebufferPluginEntry> duplication(const std::string& name) {
            auto dup = std::make_shared<QGaSerialRebufferPluginEntry>(name, typeKey_, ver_);
            dup->sn_ = sn_;
            return dup;
        }

        virtual void setDataPool(QGAPortPool &pool) { pool_= &pool;};

        virtual bool rebuildBufferBytes(const QByte *srcbuff, int32_t srclen, QRByte &newbuff, size_t& newlen) {
            return false;
        }

        void setAnalyzer(JEDPRAnalyzer analyzer) {
            analyzer_ = analyzer;
        }
    };

    using QGaSerialRebufferPluginEntryR = std::shared_ptr<QGaSerialRebufferPluginEntry>;
}

#endif //INC_1_LIBDEVCPP_QGACYPHERPLUGINENTRY_H
