欢迎您访问365答案网,请分享给你的朋友!
生活常识 学习资料

EOS源代码解读(2)插件-插件模板

时间:2023-06-13

eos/plugins/template_plugin定义了eos项目中所有插件的模板

class template_plugin : public appbase::plugin {public: template_plugin(); virtual ~template_plugin(); APPbase_PLUGIN_REQUIRES() virtual void set_program_options(options_description&, options_description& cfg) override; void plugin_initialize(const variables_map& options); void plugin_startup(); void plugin_shutdown();private: std::unique_ptr my;}; static appbase::abstract_plugin& _template_plugin = app().register_plugin();class template_plugin_impl { public:};template_plugin::template_plugin():my(new template_plugin_impl()){}template_plugin::~template_plugin(){}void template_plugin::set_program_options(options_description&, options_description& cfg) { cfg.add_options() ("option-name", bpo::value()->default_value("default value"), "Option Description") ;}void template_plugin::plugin_initialize(const variables_map& options) { try { if( options.count( "option-name" )) { // Handle the option } } FC_LOG_AND_RETHROW()}void template_plugin::plugin_startup() { // Make the magic happen}void template_plugin::plugin_shutdown() { // OK, that's enough magic}

Copyright © 2016-2020 www.365daan.com All Rights Reserved. 365答案网 版权所有 备案号:

部分内容来自互联网,版权归原作者所有,如有冒犯请联系我们,我们将在三个工作时内妥善处理。