view libirccd-daemon/irccd/daemon/dynlib_plugin.hpp @ 809:8460b4a34191

misc: reorganize namespaces, closes #952 @4h
author David Demelier <markand@malikania.fr>
date Fri, 16 Nov 2018 12:25:00 +0100
parents libirccd/irccd/daemon/dynlib_plugin.hpp@ca16ca53c347
children 49fa22f0b4b9
line wrap: on
line source

/*
 * dynlib_plugin.hpp -- native plugin implementation
 *
 * 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.
 */

#ifndef IRCCD_DAEMON_DYNLIB_PLUGIN_HPP
#define IRCCD_DAEMON_DYNLIB_PLUGIN_HPP

/**
 * \file dynlib_plugin.hpp
 * \brief Native plugin implementation.
 */

#define BOOST_DLL_FORCE_ALIAS_INSTANTIATION
#include <boost/dll.hpp>

#include "plugin.hpp"

namespace irccd::daemon {

/**
 * \ingroup plugins
 * \brief Implementation for searching native plugins.
 */
class dynlib_plugin_loader : public plugin_loader {
public:
	/**
	 * Constructor.
	 *
	 * \param directories optional directories to search, if empty use defaults.
	 */
	dynlib_plugin_loader(std::vector<std::string> directories = {}) noexcept;

	/**
	 * \copydoc plugin_loader::open
	 */
	auto open(std::string_view id, std::string_view file) -> std::shared_ptr<plugin> override;
};

} // !irccd::daemon

#endif // !IRCCD_DAEMON_DYNLIB_PLUGIN_HPP