21int main(
int argc,
char* argv[]) {
40 map<string, Shape*> fffv;
46 Shape* aShape = fffv[
"triangle"];
50 fffv[
"triangle"]->Area();
53 log->info(0,
" Shape pointers from map: ", fffv[
"triangle"],
", from direct pointer:", aShape);
65 map<string, std::shared_ptr<Car>> ggg;
71 auto aCar = ggg[
"ford"];
77 log->info(0,
" Car pointers from map: ", ggg[
"ford"],
", from direct pointer:", aCar);
78 log->info(0,
" run generalCarVar method from factory map: ", ggg[
"tesla"]->generalCarVar);
Example concrete Shape implementation used in static registration.
Example base class used to demonstrate dynamic factory loading.
Factory registry and dynamic-library manager for run-time creation of plugin objects.
std::shared_ptr< T > LoadAndRegisterObjectFromLibrary(std::string_view name, const std::shared_ptr< GOptions > &gopts)
Load a plugin library and instantiate an object from it.
Base * CreateObject(std::string_view name) const
Create an instance of a previously registered factory.
void RegisterObjectFactory(std::string_view name)
Register a concrete factory under a string key.
Example base class used to demonstrate static factory registration.
virtual void Area()=0
Compute or report the shape area (example API).
Example concrete Shape implementation used in static registration.
Generic factory/manager for GEMC plugin objects.
constexpr const char * PLUGIN_LOGGER
Logger channel used by the gfactory module and plugins loaded through it.
GOptions defineOptions()
Define the command-line/options set used by the gfactory module.
int main(int argc, char *argv[])