/* * Copyright (c) 2015 Cryptonomex, Inc., and contributors. * * The MIT License * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ #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(plug->plugin_name() + " plugin. " + plug->plugin_description() + "\nOptions"), plugin_cfg_options; //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_available_plugin( 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; void enable_plugin( const string& name ); bool is_plugin_enabled(const string& name) const; std::shared_ptr elasticsearch_thread; private: void add_available_plugin( std::shared_ptr p ); std::shared_ptr my; boost::program_options::options_description _cli_options; boost::program_options::options_description _cfg_options; }; } }