gsystem
Loading...
Searching...
No Matches
systemDynamicFactory.h
Go to the documentation of this file.
1#pragma once
2
3// gemc
4#include "goptions.h"
5#include "gbase.h"
6
7// system plugin factory
8// this file is kept here in case in the future we'll need a gsystem plugin
9
27class GSystemDynamicFactory : public GBase<GSystemDynamicFactory>
28{
29public:
36 virtual void loadSystem(GSystem* s, int verbosity) = 0;
37
38 virtual ~GSystemDynamicFactory() = default;
39
50 static GSystemDynamicFactory* instantiate(const dlhandle h, std::shared_ptr<GOptions> g) {
51 if (!h) return nullptr;
52 using fptr = GSystemDynamicFactory* (*)(std::shared_ptr<GOptions>);
53
54 // Must match the extern "C" declaration in the derived factories.
55 auto sym = dlsym(h, "GSystemDynamicFactory");
56 if (!sym) return nullptr;
57
58 auto func = reinterpret_cast<fptr>(sym);
59 return func(g);
60 }
61};
Optional plugin interface for dynamically-loaded system factories.
virtual void loadSystem(GSystem *s, int verbosity)=0
Load a system with an explicit verbosity.
virtual ~GSystemDynamicFactory()=default
static GSystemDynamicFactory * instantiate(const dlhandle h, std::shared_ptr< GOptions > g)
Instantiate a dynamic factory from a shared-library handle.
Represents a single detector system (e.g., calorimeter, tracker).
Definition gsystem.h:32
void * dlhandle