Mercurial > irccd
view tests/src/libirccd/dynlib-plugin/test_plugin.cpp @ 684:8d93e415c3b4
Irccd: load directly native plugin instead of wrapping it, closes #790 @1h
The boost::dll::import function support importing variables as
boost::shared_ptr, instead of wrapping all individual function, just load the
plugin from the shared object and return it as a std::shared_ptr.
author | David Demelier <markand@malikania.fr> |
---|---|
date | Fri, 13 Apr 2018 07:32:10 +0200 |
parents | 152d20dc0e74 |
children | 48afa8c41f50 |
line wrap: on
line source
/* * test_plugin.cpp -- basic exported plugin test * * Copyright (c) 2013-2018 David Demelier <markand@malikania.fr> * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include <boost/dll.hpp> #include <irccd/daemon/plugin.hpp> namespace irccd { class test_plugin : public plugin { private: plugin_config config_; public: using plugin::plugin; plugin_config get_config() override { return config_; } void handle_command(irccd&, const message_event&) override { config_["command"] = "true"; } void handle_connect(irccd&, const connect_event&) override { config_["connect"] = "true"; } void handle_invite(irccd&, const invite_event&) override { config_["invite"] = "true"; } void handle_join(irccd&, const join_event&) override { config_["join"] = "true"; } void handle_kick(irccd&, const kick_event&) override { config_["kick"] = "true"; } void handle_load(irccd&) override { config_["load"] = "true"; } void handle_message(irccd&, const message_event&) override { config_["message"] = "true"; } void handle_me(irccd&, const me_event&) override { config_["me"] = "true"; } void handle_mode(irccd&, const mode_event&) override { config_["mode"] = "true"; } void handle_names(irccd&, const names_event&) override { config_["names"] = "true"; } void handle_nick(irccd&, const nick_event&) override { config_["nick"] = "true"; } void handle_notice(irccd&, const notice_event&) override { config_["notice"] = "true"; } void handle_part(irccd&, const part_event&) override { config_["part"] = "true"; } void handle_reload(irccd&) override { config_["reload"] = "true"; } void handle_topic(irccd&, const topic_event&) override { config_["topic"] = "true"; } void handle_unload(irccd&) override { config_["unload"] = "true"; } void handle_whois(irccd&, const whois_event&) override { config_["whois"] = "true"; } }; extern "C" BOOST_SYMBOL_EXPORT test_plugin irccd_plugin_test_plugin; test_plugin irccd_plugin_test_plugin("test", ""); } // !irccd