BitShares-Core  5.0.0
BitShares blockchain implementation and command-line interface software
template_plugin.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018 template_plugin and contributors.
3  *
4  * The MIT License
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a copy
7  * of this software and associated documentation files (the "Software"), to deal
8  * in the Software without restriction, including without limitation the rights
9  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10  * copies of the Software, and to permit persons to whom the Software is
11  * furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in
14  * all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22  * THE SOFTWARE.
23  */
24 
26 
27 namespace graphene { namespace template_plugin {
28 
29 namespace detail
30 {
31 
33 {
34  public:
36  : _self( _plugin )
37  { }
38  virtual ~template_plugin_impl();
39 
40  void onBlock( const signed_block& b );
41 
43  {
44  return _self.database();
45  }
46 
48 
49  std::string _plugin_option = "";
50 
51  private:
52 
53 };
54 
55 void template_plugin_impl::onBlock( const signed_block& b )
56 {
57  wdump((b.block_num()));
58 }
59 
61 {
62  return;
63 }
64 
65 } // end namespace detail
66 
68  my( new detail::template_plugin_impl(*this) )
69 {
70 }
71 
73 {
74 }
75 
76 std::string template_plugin::plugin_name()const
77 {
78  return "template_plugin";
79 }
81 {
82  return "template_plugin description";
83 }
84 
86  boost::program_options::options_description& cli,
87  boost::program_options::options_description& cfg
88  )
89 {
90  cli.add_options()
91  ("template_plugin_option", boost::program_options::value<std::string>(), "template_plugin option")
92  ;
93  cfg.add(cli);
94 }
95 
96 void template_plugin::plugin_initialize(const boost::program_options::variables_map& options)
97 {
98  database().applied_block.connect( [&]( const signed_block& b) {
99  my->onBlock(b);
100  } );
101 
102  if (options.count("template_plugin")) {
103  my->_plugin_option = options["template_plugin"].as<std::string>();
104  }
105 }
106 
108 {
109  ilog("template_plugin: plugin_startup() begin");
110 }
111 
112 } }
std::unique_ptr< detail::template_plugin_impl > my
fc::signal< void(const signed_block &)> applied_block
Definition: database.hpp:197
tracks the blockchain state in an extensible manner
Definition: database.hpp:70
Definition: api.cpp:56
virtual void plugin_set_program_options(boost::program_options::options_description &cli, boost::program_options::options_description &cfg) override
Fill in command line parameters used by the plugin.
#define wdump(SEQ)
Definition: logger.hpp:174
chain::database & database()
Definition: plugin.hpp:114
std::string plugin_name() const override
#define ilog(FORMAT,...)
Definition: logger.hpp:117
std::string plugin_description() const override
virtual void plugin_startup() override
Begin normal runtime operations.
virtual void plugin_initialize(const boost::program_options::variables_map &options) override
Perform early startup routines and register plugin indexes, callbacks, etc.