//
// Created by Ht on 2022/2/9.
//

#ifndef LIBDEVCPP_MGOPERATORACCESSOR_H
#define LIBDEVCPP_MGOPERATORACCESSOR_H

#include <mgbus/MgBusService.h>


namespace jedge {
    class JE_API MgOperatorAccessor :
            public MgService,
            public MgTriggerManagerOperator {
    public:
        explicit MgOperatorAccessor(jedge::ChannelOperator &opr, const std::string &name, const qlibc::QData &config) :
                MgService(opr, name, config, false),
                MgTriggerManagerOperator(dynamic_cast<ChannelOperator&>(opr)) {
        }

        void printEventsDefined(Json::Value *ret) override {
            Json::Value *vl = nullptr;
            if(ret!=nullptr) {
                ret->operator[]("h") = Json::arrayValue;
                vl = & ret->operator[]("h");
            }
            auto baseUri = name();
            for (const auto& k : _evList) {
                QLog("Service api loaded(%s) : %s%s", baseUri.c_str(), qlog_light_green, k.c_str());
                if(vl!=nullptr) vl->append(k);
            }
        }
    };
}


#endif //LIBDEVCPP_MGOPERATORACCESSOR_H
