41 virtual void go() = 0;
49 void set_loggers([[ maybe_unused ]]
const std::shared_ptr<GOptions>& g) {
82 if (!h)
return nullptr;
85 using fptr =
Car* (*)(std::shared_ptr<GOptions>);
89 auto sym = dlsym(h,
"CarFactory");
90 if (!sym)
return nullptr;
94 auto func =
reinterpret_cast<fptr
>(sym);
Example base class used to demonstrate dynamic factory loading.
static Car * instantiate(const dlhandle h, std::shared_ptr< GOptions > g)
Resolve the plugin factory symbol and instantiate a derived Car.
virtual void go()=0
Example pure-virtual behavior implemented by each plugin.
void set_loggers(const std::shared_ptr< GOptions > &g)
Wire loggers into the object.
Car(const std::shared_ptr< GOptions > &g)
Construct the base with a shared options/configuration instance.
~Car() override=default
Virtual destructor for polymorphic deletion.
double generalCarVar
Example data member shared by all derived cars.
void * dlhandle
Opaque handle returned by dlopen and consumed by dlsym / dlclose.
constexpr const char * PLUGIN_LOGGER
Logger channel used by the gfactory module and plugins loaded through it.