110 TTHREAD_TLS(
bool) readingDirs (
false);
120 const
char *className, const
char *pluginName,
121 const
char *ctor, const
char *origin):
134 TString aclicMode, arguments, io;
141 if (validMacro &&
gROOT->LoadMacro(fPlugin, 0,
kTRUE) == 0)
144 if (fCtor.BeginsWith(
"::")) {
195 using exit_scope = std::shared_ptr<void*>;
196 exit_scope guard(
nullptr,
197 [
this,&setCanCall](
void *) { this->
fCanCall = setCanCall; } );
202 Error(
"SetupCallEnv",
"class %s not found in plugin %s",
fClass.
Data(),
215 fMethod = cl->GetMethodWithPrototype(method, proto);
220 Error(
"SetupCallEnv",
"global function %s not found", method.
Data());
222 Error(
"SetupCallEnv",
"method %s not found in class %s", method.
Data(),
228 Error(
"SetupCallEnv",
"method %s is not public", method.
Data());
275 Error(
"ExecPlugin",
"no ctor specified for this handler %s",
fClass.
Data());
293 Error(
"ExecPlugin",
"nargs (%d) not consistent with expected number of arguments ([%d-%d])",
308 const char *exist =
"";
314 if (strchr(opt,
'a')) {
320 if (path)
Printf(
" [Lib: %s]", path);
358 if ((s = strstr(er->GetName(),
"Plugin."))) {
362 const char *val = env->
GetValue(s, (
const char*)0);
368 TString regexp = strtok(!cnt ? v : 0,
"; ");
369 if (regexp.
IsNull())
break;
370 TString clss = strtok(0,
"; ");
372 TString plugin = strtok(0,
"; ");
373 if (plugin.
IsNull())
break;
374 TString ctor = strtok(0,
";\"");
376 ctor = strtok(0,
";\"");
377 AddHandler(s, regexp, clss, plugin, ctor,
"TEnv");
394 Info(
"LoadHandlerMacros",
"%s", path);
400 if (f[0] ==
'P' && f.
EndsWith(
".C")) {
413 Info(
"LoadHandlerMacros",
" plugin macro: %s", s->
String().
Data());
416 Error(
"LoadHandlerMacros",
"pluging macro %s returned %ld",
481 for (
Int_t j = 0; j < i; j++) {
497 Info(
"LoadHandlersFromPluginDirs",
"%s", d.
Data());
521 const char *className,
const char *pluginName,
522 const char *ctor,
const char *origin)
538 pluginName, ctor, origin);
558 if (h->
fBase == base) {
559 if (!regexp || h->
fRegexp == regexp) {
583 Info(
"FindHandler",
"found plugin for %s", h->
GetClass());
590 Info(
"FindHandler",
"did not find plugin for class %s and uri %s", base, uri);
592 Info(
"FindHandler",
"did not find plugin for class %s", base);
610 Printf(
"=====================================================================");
611 Printf(
"Base Regexp Class Plugin");
612 Printf(
"=====================================================================");
620 Printf(
"=====================================================================");
621 Printf(
"%d plugin handlers registered", cnt);
622 Printf(
"[*] %d %s not available", cntmiss, cntmiss==1 ?
"plugin" :
"plugins");
623 Printf(
"=====================================================================\n");
645 Error(
"WritePluginMacros",
"cannot write in directory %s", d.
Data());
655 if (plugin && strcmp(plugin, h->
fBase) && strcmp(plugin, h->
fClass)) {
659 if (base != h->
fBase) {
670 Error(
"WritePluginMacros",
"cannot create directory %s", sdd.
Data());
677 FILE *
f = fopen(fd,
"w");
679 fprintf(f,
"void P%03d_%s()\n{\n", idx, h->
fClass.
Data());
680 fprintf(f,
" gPluginMgr->AddHandler(\"%s\", \"%s\", \"%s\",\n",
692 fprintf(f,
" gPluginMgr->AddHandler(\"%s\", \"%s\", \"%s\",\n",
723 if (!envFile || !envFile[0])
726 fd = fopen(envFile,
"w+");
729 Error(
"WritePluginRecords",
"error opening file %s", envFile);
739 if (plugin && strcmp(plugin, h->
fBase) && strcmp(plugin, h->
fClass)) {
743 if (base != h->
fBase) {
752 fprintf(fd,
"Plugin.%s: %s %s %s \"%s\"\n", base2.
Data(), h->
fRegexp.
Data(),
755 fprintf(fd,
"+Plugin.%s: %s %s %s \"%s\"\n", base2.
Data(), h->
fRegexp.
Data(),
766 fprintf(fd,
"+Plugin.%s: %s %s %s \"%s\"\n", base2.
Data(), h2->
fRegexp.
Data(),
775 if (envFile && envFile[0])
virtual Bool_t AccessPathName(const char *path, EAccessMode mode=kFileExists)
Returns FALSE if one can access a file using the specified access mode.
virtual TString SplitAclicMode(const char *filename, TString &mode, TString &args, TString &io) const
This method split a filename of the form: ~~~ {.cpp} [path/]macro.C[+|++[k|f|g|O|c|s|d|v|-]][(args)]...
void LoadHandlerMacros(const char *path)
Load all plugin macros from the specified path/base directory.
Bool_t MaybeRegexp() const
Returns true if string contains one of the regexp characters "^$.[]*+?".
ClassImp(TSeqCollection) Int_t TSeqCollection TIter next(this)
Return index of object in collection.
Collectable string class.
R__EXTERN TVirtualMutex * gInterpreterMutex
TString & ReplaceAll(const TString &s1, const TString &s2)
Int_t WritePluginRecords(const char *envFile, const char *plugin=0) const
Write in the specified environment config file the plugin records.
Int_t GetNargs() const
Number of function arguments.
virtual void SetOwner(Bool_t enable=kTRUE)
Set whether this collection is the owner (enable==true) of its content.
THashTable * fBasesLoaded
void RemoveHandler(const char *base, const char *regexp=0)
Remove handler for the specified base class and the specified regexp.
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
virtual int MakeDirectory(const char *name)
Make a directory.
void Print(Option_t *opt="") const
Print info about the plugin handler.
Regular expression class.
This class implements a mutex interface.
TPluginHandler * FindHandler(const char *base, const char *uri=0)
Returns the handler if there exists a handler for the specified URI.
void LoadHandlersFromEnv(TEnv *env)
Load plugin handlers specified in config file, like: Plugin.TFile: ^rfio: TRFIOFile RFI...
Int_t LoadPlugin()
Load the plugin library for this handler.
The TEnv class reads config files, by default named .rootrc.
Int_t GetEntriesFast() const
Bool_t BeginsWith(const char *s, ECaseCompare cmp=kExact) const
const char * Data() const
static bool & TPH__IsReadingDirs()
void SetupCallEnv()
Setup ctor or static method call environment.
virtual const char * GetDirEntry(void *dirp)
Get a directory entry. Returns 0 if no more entries.
THashTable implements a hash table to store TObject's.
UChar_t mod R__LOCKGUARD2(gSrvAuthenticateMutex)
void LoadHandlersFromPluginDirs(const char *base=0)
Load plugin handlers specified via macros in a list of plugin directories.
void Init(const TFunction *func)
Initialize the method invocation environment based on the TFunction object.
A sorted doubly linked list.
TClass * fClass
pointer to the foreign object
Bool_t CheckForExecPlugin(Int_t nargs)
Check that we can properly run ExecPlugin.
Method or function calling interface.
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
ClassImp(TPluginHandler) TPluginHandler
Create a plugin handler. Called by TPluginManager.
Int_t GetNargsOpt() const
Number of function optional (default) arguments.
void AddHandler(const char *base, const char *regexp, const char *className, const char *pluginName, const char *ctor=0, const char *origin=0)
Add plugin handler to the list of handlers.
Bool_t EndsWith(const char *pat, ECaseCompare cmp=kExact) const
Return true if string ends with the specified string.
R__EXTERN TSystem * gSystem
virtual Int_t GetValue(const char *name, Int_t dflt)
Returns the integer value for a resource.
virtual TObject * Remove(TObject *obj)
Remove object from the list.
TObject * GetObject() const
void Form(const char *fmt,...)
Formats a string using a printf style format descriptor.
This class implements a plugin library manager.
The ROOT global object gROOT contains a list of all defined classes.
Long_t Property() const
Get property description word. For meaning of bits see EProperty.
virtual TObjLink * FirstLink() const
THashList * GetTable() const
virtual void FreeDirectory(void *dirp)
Free a directory.
TObjArray * Tokenize(const TString &delim) const
This function is used to isolate sequential tokens in a TString.
char * StrDup(const char *str)
Duplicate the string str.
AtomicInt_t fCanCall
ctor method or global function
char * DynamicPathName(const char *lib, Bool_t quiet=kFALSE)
Find a dynamic library called lib using the system search paths.
Wrapper around a TObject so it can be stored in a TList.
Bool_t fIsMacro
if 1 fCallEnv is ok, -1 fCallEnv is not ok, 0 fCallEnv not setup yet.
void Add(TObject *obj)
Add object to the hash table.
static TVirtualMutex * gPluginManagerMutex
void Print(Option_t *opt="") const
Print list of registered plugin handlers.
static TClass * GetClass(const char *name, Bool_t load=kTRUE, Bool_t silent=kFALSE)
Static method returning pointer to TClass of the specified class name.
static TClass * LoadClass(const char *requestedname, Bool_t silent)
Helper function used by TClass::GetClass().
Bool_t CanHandle(const char *base, const char *uri)
Check if regular expression appears in the URI, if so return kTRUE.
Int_t WritePluginMacros(const char *dir, const char *plugin=0) const
Write in the specified directory the plugin macros.
Int_t CheckPlugin() const
Check if the plugin library for this handler exits.
virtual void Add(TObject *obj)
TPluginManager * gPluginMgr
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
TObject * FindObject(const char *name) const
Find object using its name.
virtual void * OpenDirectory(const char *name)
Open a directory. Returns 0 if directory does not exist.
TObject * At(Int_t idx) const
~TPluginHandler()
Cleanup plugin handler object.
const char * GetClass() const
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
TFunction * fMethod
ctor method call environment
virtual char * ConcatFileName(const char *dir, const char *name)
Concatenate a directory and a file name. User must delete returned string.
static char * skip(char **buf, const char *delimiters)