EOS 源代码解读 插件-插件模板
Posted thefist11
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了EOS 源代码解读 插件-插件模板相关的知识,希望对你有一定的参考价值。
eos/plugins/template_plugin定义了eos项目中所有插件的模板
/**
* This is a template plugin, intended to serve as a starting point for making new plugins
*/
class template_plugin : public appbase::plugin<template_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<class template_plugin_impl> my;
;
static appbase::abstract_plugin& _template_plugin = app().register_plugin<template_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<string>()->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
以上是关于EOS 源代码解读 插件-插件模板的主要内容,如果未能解决你的问题,请参考以下文章
EOS 源代码解读 插件-set_program_options