MakePlugify creates the core with all defaults and the given base folder. Extensions are looked for in <base>/extensions.
main.cpp
#include <plugify/plugify.hpp>
#include <iostream>
int main() {
auto result = plugify::MakePlugify("./app");
if (!result) {
std::cerr << "Failed to create Plugify: " << result.error() << '\n';
return 1;
}
auto plugify = result.value();
if (auto init = plugify->Initialize(); !init) {
std::cerr << "Failed to initialize: " << init.error() << '\n';
return 1;
}
// Find, check and load modules and plugins
const auto& manager = plugify->GetManager();
if (auto load = manager.Initialize(); !load) {
std::cerr << "Failed to load extensions: " << load.error() << '\n';
}
bool running = true;
while (running) {
plugify->Update();
// Your application logic here
}
plugify->Terminate();
return 0;
}
Initialize() of the core checks the folders: the base folder must exist, the others are created. GetManager().Initialize() loads the extensions. If one extension fails, the others are still loaded and the core logs a report; an error is returned only when nothing can be loaded at all.
The core cannot reload a single plugin. To reload everything, call GetManager().Terminate() and then GetManager().Initialize(): the manifests are read again and the extensions are loaded from disk.
An extension did not start. Look at the report the core logs after loading: it gives the reason for every extension that did not start. Set logging.printReport to also get timings.
"Validation failed: baseDir does not exist". Create the base folder or pass a path that exists. Relative paths are taken from the current folder of the process.
Build errors. Check that your compiler supports C++23 and that CMake is 3.14 or later.