27 static inline ComponentCast* component(
void* p) {
return (ComponentCast*)p; }
32 except(
"createProcessor",
"++ dd4hep-plugins: No processor creator name given!");
34 for(
int i=0; i<argc; ++i) {
35 if ( 0 == ::strncmp(argv[i],
"-processor",4) ) {
36 std::vector<char*> args;
37 std::string fac = argv[++i];
38 for(
int j=++i; j<argc && argv[j] &&
39 0 != ::strncmp(argv[j],
"-processor",4) &&
40 0 != ::strncmp(argv[j],
"-end-processor",8); ++j)
41 args.emplace_back(argv[j]);
42 int num_arg = int(args.size());
43 args.emplace_back(
nullptr);
44 processor = PluginService::Create<void*>(fac,&description,num_arg,&args[0]);
47 processor = PluginService::Create<void*>(fac,&description,num_arg,&args[0]);
49 except(
"createProcessor",
"dd4hep-plugins: Failed to locate plugin %s. \n%s %s",
55 void* obj = cast(processor);
56 if ( obj )
return obj;
57 ComponentCast* c = component(processor);
58 invalidHandleAssignmentError(
typeid(cast),
typeid(*c));
63 except(
"createProcessor",
64 "dd4hep-plugins: Found arguments in plugin call, but could not make any sense of them: %s",
65 arguments(argc,argv).c_str());
70 void*
createPlugin(
const std::string& factory,
Detector& description,
int argc,
char** argv,
void* (*cast)(
void*)) {
71 void*
object = PluginService::Create<void*>(factory, &description, argc, argv);
74 object = PluginService::Create<void*>(factory, &description, argc, argv);
76 except(
"createPlugin",
"dd4hep-plugins: Failed to locate plugin %s. \n%s.",
81 void* obj = cast(
object);
82 if ( obj )
return obj;
83 ComponentCast* c = component(
object);
84 invalidHandleAssignmentError(
typeid(cast),
typeid(*c));
93 return createPlugin(factory, description, argc, argv, cast);
98 const std::string& arg,
99 void* (*cast)(
void*)) {
100 char* argv[] = { (
char*)arg.c_str(), 0 };
102 return createPlugin(factory, description, argc, argv, cast);