diff options
Diffstat (limited to 'plugin.cpp')
-rw-r--r-- | plugin.cpp | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/plugin.cpp b/plugin.cpp new file mode 100644 index 0000000..9c47ed2 --- /dev/null +++ b/plugin.cpp @@ -0,0 +1,36 @@ +#include "plugin.h" + +#include <boost/dll/import.hpp> +#include <boost/shared_ptr.hpp> +#include <boost/filesystem.hpp> + +#include <iostream> +#include <filesystem> + +#include "plugin_interface.h" + +namespace dll = boost::dll; +namespace fs = std::filesystem; +using namespace std::string_literals; + +void load_plugins(Config& config) +{ + const auto& plugin_directories{config.PluginDirectories()}; + + for (const auto& dir: plugin_directories) { + for (auto& path: fs::recursive_directory_iterator(dir)) { + if (path.is_regular_file()) { + + dll::fs::path lib_path{path.path()}; + + boost::shared_ptr<webserver_plugin_interface> plugin = dll::import<webserver_plugin_interface>(lib_path, "webserver_plugin", dll::load_mode::append_decorations); + if (!plugin) + throw std::runtime_error("Can't load plugin"); + + std::cout << "Plugin: " << plugin->generate_page("a") << std::endl; + } + } + } + +} + |