33 lines
884 B
C++
33 lines
884 B
C++
#pragma once
|
|
#include <Mod/Context.hpp>
|
|
#include <Mods/Loaded.hpp>
|
|
#include <Mods/Registry.hpp>
|
|
#include <memory>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
namespace vl::mod {
|
|
|
|
// Handles dlopen/dlsym, discovers mod registrations, constructs mods (C2)
|
|
class ModLoader {
|
|
public:
|
|
// Load a module (.so), discover CRTP-registered mod types, instantiate each with Context.
|
|
// Returns the number of instances created from this module.
|
|
std::size_t loadModule(const std::string& path, const Context& ctx);
|
|
|
|
// Start/stop all currently loaded instances.
|
|
void startAll();
|
|
void stopAll();
|
|
|
|
// Unload everything (calls stopAll first if not stopped).
|
|
void unloadAll();
|
|
|
|
const std::vector<LoadedMod>& instances() const noexcept { return instances_; }
|
|
|
|
private:
|
|
std::vector<void*> handles_;
|
|
std::vector<LoadedMod> instances_;
|
|
};
|
|
|
|
} // namespace vl::log
|