/* * Copyright (c) 2015 Cryptonomex, Inc., and contributors. All rights reserved. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ #pragma once #include #include #include #include namespace graphene { namespace app { namespace detail { class application_impl; } using std::string; class abstract_plugin; class application { public: application(); ~application(); void set_program_options( boost::program_options::options_description& command_line_options, boost::program_options::options_description& configuration_file_options )const; void initialize(const fc::path& data_dir, const boost::program_options::variables_map&options); void initialize_plugins( const boost::program_options::variables_map& options ); void startup(); void shutdown(); void startup_plugins(); void shutdown_plugins(); template std::shared_ptr register_plugin() { auto plug = std::make_shared(); plug->plugin_set_app(this); boost::program_options::options_description plugin_cli_options("Options for plugin " + plug->plugin_name()), plugin_cfg_options; plug->plugin_set_program_options(plugin_cli_options, plugin_cfg_options); if( !plugin_cli_options.options().empty() ) _cli_options.add(plugin_cli_options); if( !plugin_cfg_options.options().empty() ) _cfg_options.add(plugin_cfg_options); add_plugin( plug->plugin_name(), plug ); return plug; } std::shared_ptr get_plugin( const string& name )const; template std::shared_ptr get_plugin( const string& name ) const { std::shared_ptr abs_plugin = get_plugin( name ); std::shared_ptr result = std::dynamic_pointer_cast( abs_plugin ); FC_ASSERT( result != std::shared_ptr() ); return result; } net::node_ptr p2p_node(); std::shared_ptr chain_database()const; void set_block_production(bool producing_blocks); fc::optional< api_access_info > get_api_access_info( const string& username )const; void set_api_access_info(const string& username, api_access_info&& permissions); bool is_finished_syncing()const; /// Emitted when syncing finishes (is_finished_syncing will return true) boost::signals2::signal syncing_finished; private: void add_plugin( const string& name, std::shared_ptr p ); std::shared_ptr my; boost::program_options::options_description _cli_options; boost::program_options::options_description _cfg_options; }; } }