view tests/src/libirccd/dynlib-plugin/test_plugin.cpp @ 716:16e83b636cb8

Irccd: use BOOST_DLL_ALIAS to avoid warnings
author David Demelier <markand@malikania.fr>
date Mon, 09 Jul 2018 20:53:00 +0200
parents 48afa8c41f50
children 3e816cebed2c
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";
    }

    static auto abi() -> version
    {
        return version();
    }

    static auto init() -> std::unique_ptr<plugin>
    {
        return std::make_unique<test_plugin>("testplugin", "");
    }
};

BOOST_DLL_ALIAS(test_plugin::abi, irccd_abi_test_plugin)
BOOST_DLL_ALIAS(test_plugin::init, irccd_init_test_plugin)

} // !irccd