library: libCore #include "TPluginManager.h" |
TPluginHandler
class description - source file - inheritance tree (.pdf)
private:
TPluginHandler()
TPluginHandler(const char* base, const char* regexp, const char* className, const char* pluginName, const char* ctor)
~TPluginHandler()
Bool_t CanHandle(const char* base, const char* uri)
const char* GetBase() const
const char* GetCtor() const
const char* GetPlugin() const
const char* GetRegexp() const
void SetupCallEnv()
public:
TPluginHandler(const TPluginHandler&)
Int_t CheckPlugin()
static TClass* Class()
Long_t ExecPlugin(Int_t nargs)
const char* GetClass() const
virtual TClass* IsA() const
Int_t LoadPlugin()
TPluginHandler& operator=(const TPluginHandler&)
virtual void ShowMembers(TMemberInspector& insp, char* parent)
virtual void Streamer(TBuffer& b)
void StreamerNVirtual(TBuffer& b)
private:
TString fBase base class which will be extended by plugin
TString fRegexp regular expression which must be matched in URI
TString fClass class to be loaded from plugin library
TString fPlugin plugin library which should contain fClass
TString fCtor ctor used to instantiate object of fClass
TMethodCall* fCallEnv !ctor method call environment
TFunction* fMethod !ctor method or global function
Int_t fCanCall !if 1 fCallEnv is ok, -1 fCallEnv is not ok
Bool_t fIsMacro plugin is a macro and not a library
Bool_t fIsGlobal plugin ctor is a global function
TPluginManager
This class implements a plugin library manager. It keeps track of
a list of plugin handlers. A plugin handler knows which plugin
library to load to get a specific class that is used to extend the
functionality of a specific base class and how to create an object
of this class. For example, to extend the base class TFile to be
able to read RFIO files one needs to load the plugin library
libRFIO.so which defines the TRFIOFile class. This loading should
be triggered when a given URI contains a regular expression defined
by the handler. Handlers can be defined for example as resources
in the .rootrc file, e.g.:
Plugin.TFile: ^rfio: TRFIOFile RFIO "<constructor>"
Plugin.TSQLServer: ^mysql: TMySQLServer MySQL "<constructor>"
+Plugin.TSQLServer: ^pgsql: TPgSQLServer PgSQL "<constructor>"
Plugin.TVirtualFitter: * TFitter Minuit "TFitter(Int_t)"
Where the + in front of Plugin.TSQLServer says that it extends the
existing definition of TSQLServer, usefull when there is more than
one plugin that can extend the same base class. The "<constructor>"
should be the constructor or a static method that generates an
instance of the specified class. Global methods should start with
"::" in their name, like "::CreateFitter()".
Instead of being a shared library a plugin can also be a CINT
script, so instead of libDialog.so one can have Dialog.C.
The * is a placeholder in case there is no need for a URI to
differentiate between different plugins for the same base class.
For the default plugins see $ROOTSYS/etc/system.rootrc.
Plugin handlers can also be registered at run time, e.g.:
gROOT->GetPluginManager()->AddHandler("TSQLServer", "^sapdb:",
"TSapDBServer", "SapDB",
"TSapDBServer(const char*,const char*, const char*)");
A list of currently defined handlers can be printed using:
gROOT->GetPluginManager()->Print(); // use option="a" to see ctors
The use of the plugin library manager removes all textual references
to hard-coded class and library names and the resulting dependencies
in the base classes. The plugin manager is used to extend a.o.
TFile, TSQLServer, TGrid, etc. functionality.
TPluginHandler(const char *base, const char *regexp,
const char *className, const char *pluginName,
const char *ctor)
Create a plugin handler. Called by TPluginManager.
~TPluginHandler()
Cleanup plugin handler object.
Bool_t CanHandle(const char *base, const char *uri)
Check if regular expression appears in the URI, if so return kTRUE.
If URI = 0 always return kTRUE.
void SetupCallEnv()
Setup ctor or static method call environment.
Int_t CheckPlugin()
Check if the plugin library for this handler exits. Returns 0
when it exists and -1 in case the plugin does not exist.
Int_t LoadPlugin()
Load the plugin library for this handler. Returns 0 on successful loading
and -1 in case the library does not exist or in case of error.
Long_t ExecPlugin(Int_t va_(nargs), ...)
Execute ctor for this plugin and return pointer to object of specific
class. User must cast the returned long to the correct class.
This method accepts a variable number of arguments to be passed
to the ctor, where nargs is the number of arguments, followed
by nargs arguments. Returns 0 in case of error.
Inline Functions
TPluginHandler TPluginHandler(const char* base, const char* regexp, const char* className, const char* pluginName, const char* ctor)
const char* GetBase() const
const char* GetRegexp() const
const char* GetPlugin() const
const char* GetCtor() const
const char* GetClass() const
TClass* Class()
TClass* IsA() const
void ShowMembers(TMemberInspector& insp, char* parent)
void Streamer(TBuffer& b)
void StreamerNVirtual(TBuffer& b)
TPluginHandler TPluginHandler(const TPluginHandler&)
TPluginHandler& operator=(const TPluginHandler&)
Author: Fons Rademakers 26/1/2002
Last update: root/base:$Name: $:$Id: TPluginManager.cxx,v 1.26 2005/06/22 20:18:10 brun Exp $
Copyright (C) 1995-2002, Rene Brun and Fons Rademakers. *
ROOT page - Class index - Class Hierarchy - Top of the page
This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.