ROOT logo
ROOT » CORE » BASE » TPluginManager

class TPluginManager: public TObject


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.
Plugin handlers can be defined via macros in a list of plugin
directories. With $ROOTSYS/etc/plugins the default top plugin
directory specified in $ROOTSYS/etc/system.rootrc. The macros must
have names like <BaseClass>/PX0_<PluginClass>.C, e.g.:
TFile/P10_TRFIOFile.C, TSQLServer/P20_TMySQLServer.C, etc.
to allow easy sorting and grouping. If the BaseClass is in a
namespace the directory must have the name NameSpace@@BaseClass as
: is a reserved pathname character on some operating systems.
Macros not beginning with 'P' and ending with ".C" are ignored.
These macros typically look like:

void P10_TDCacheFile()
{
gPluginMgr->AddHandler("TFile", "^dcache", "TDCacheFile",
"DCache", "TDCacheFile(const char*,Option_t*)");
}

Plugin handlers can also be defined via resources in the .rootrc
file. Although now deprecated this method still works for backward
compatibility, 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, useful 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.:

gPluginMgr->AddHandler("TSQLServer", "^sapdb:",
"TSapDBServer", "SapDB",
"TSapDBServer(const char*,const char*, const char*)");

A list of currently defined handlers can be printed using:

gPluginMgr->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.


Function Members (Methods)

public:
TPluginManager()
virtual~TPluginManager()
voidTObject::AbstractMethod(const char* method) const
voidAddHandler(const char* base, const char* regexp, const char* className, const char* pluginName, const char* ctor = 0, const char* origin = 0)
virtual voidTObject::AppendPad(Option_t* option = "")
virtual voidTObject::Browse(TBrowser* b)
static TClass*Class()
virtual const char*TObject::ClassName() const
virtual voidTObject::Clear(Option_t* = "")
virtual TObject*TObject::Clone(const char* newname = "") const
virtual Int_tTObject::Compare(const TObject* obj) const
virtual voidTObject::Copy(TObject& object) const
virtual voidTObject::Delete(Option_t* option = "")MENU
virtual Int_tTObject::DistancetoPrimitive(Int_t px, Int_t py)
virtual voidTObject::Draw(Option_t* option = "")
virtual voidTObject::DrawClass() constMENU
virtual TObject*TObject::DrawClone(Option_t* option = "") constMENU
virtual voidTObject::Dump() constMENU
virtual voidTObject::Error(const char* method, const char* msgfmt) const
virtual voidTObject::Execute(const char* method, const char* params, Int_t* error = 0)
virtual voidTObject::Execute(TMethod* method, TObjArray* params, Int_t* error = 0)
virtual voidTObject::ExecuteEvent(Int_t event, Int_t px, Int_t py)
virtual voidTObject::Fatal(const char* method, const char* msgfmt) const
TPluginHandler*FindHandler(const char* base, const char* uri = 0)
virtual TObject*TObject::FindObject(const char* name) const
virtual TObject*TObject::FindObject(const TObject* obj) const
virtual Option_t*TObject::GetDrawOption() const
static Long_tTObject::GetDtorOnly()
virtual const char*TObject::GetIconName() const
virtual const char*TObject::GetName() const
virtual char*TObject::GetObjectInfo(Int_t px, Int_t py) const
static Bool_tTObject::GetObjectStat()
virtual Option_t*TObject::GetOption() const
virtual const char*TObject::GetTitle() const
virtual UInt_tTObject::GetUniqueID() const
virtual Bool_tTObject::HandleTimer(TTimer* timer)
virtual ULong_tTObject::Hash() const
virtual voidTObject::Info(const char* method, const char* msgfmt) const
virtual Bool_tTObject::InheritsFrom(const char* classname) const
virtual Bool_tTObject::InheritsFrom(const TClass* cl) const
virtual voidTObject::Inspect() constMENU
voidTObject::InvertBit(UInt_t f)
virtual TClass*IsA() const
virtual Bool_tTObject::IsEqual(const TObject* obj) const
virtual Bool_tTObject::IsFolder() const
Bool_tTObject::IsOnHeap() const
virtual Bool_tTObject::IsSortable() const
Bool_tTObject::IsZombie() const
voidLoadHandlersFromEnv(TEnv* env)
voidLoadHandlersFromPluginDirs(const char* base = 0)
virtual voidTObject::ls(Option_t* option = "") const
voidTObject::MayNotUse(const char* method) const
virtual Bool_tTObject::Notify()
static voidTObject::operator delete(void* ptr)
static voidTObject::operator delete(void* ptr, void* vp)
static voidTObject::operator delete[](void* ptr)
static voidTObject::operator delete[](void* ptr, void* vp)
void*TObject::operator new(size_t sz)
void*TObject::operator new(size_t sz, void* vp)
void*TObject::operator new[](size_t sz)
void*TObject::operator new[](size_t sz, void* vp)
virtual voidTObject::Paint(Option_t* option = "")
virtual voidTObject::Pop()
virtual voidPrint(Option_t* opt = "") const
virtual Int_tTObject::Read(const char* name)
virtual voidTObject::RecursiveRemove(TObject* obj)
voidRemoveHandler(const char* base, const char* regexp = 0)
voidTObject::ResetBit(UInt_t f)
virtual voidTObject::SaveAs(const char* filename = "", Option_t* option = "") constMENU
virtual voidTObject::SavePrimitive(basic_ostream<char,char_traits<char> >& out, Option_t* option = "")
voidTObject::SetBit(UInt_t f)
voidTObject::SetBit(UInt_t f, Bool_t set)
virtual voidTObject::SetDrawOption(Option_t* option = "")MENU
static voidTObject::SetDtorOnly(void* obj)
static voidTObject::SetObjectStat(Bool_t stat)
virtual voidTObject::SetUniqueID(UInt_t uid)
virtual voidShowMembers(TMemberInspector& insp, char* parent)
virtual voidStreamer(TBuffer& b)
voidStreamerNVirtual(TBuffer& b)
virtual voidTObject::SysError(const char* method, const char* msgfmt) const
Bool_tTObject::TestBit(UInt_t f) const
Int_tTObject::TestBits(UInt_t f) const
virtual voidTObject::UseCurrentStyle()
virtual voidTObject::Warning(const char* method, const char* msgfmt) const
virtual Int_tTObject::Write(const char* name = 0, Int_t option = 0, Int_t bufsize = 0)
virtual Int_tTObject::Write(const char* name = 0, Int_t option = 0, Int_t bufsize = 0) const
Int_tWritePluginMacros(const char* dir, const char* plugin = 0) const
protected:
virtual voidTObject::DoError(int level, const char* location, const char* fmt, va_list va) const
voidTObject::MakeZombie()
private:
TPluginManager(const TPluginManager& pm)
voidLoadHandlerMacros(const char* path)
TPluginManager&operator=(const TPluginManager& pm)

Data Members

private:
THashTable*fBasesLoaded! table of base classes already checked or loaded
TList*fHandlerslist of plugin handlers
Bool_tfReadingDirs! true if we are running LoadHandlersFromPluginDirs

Class Charts

Inheritance Inherited Members Includes Libraries
Class Charts

Function documentation

~TPluginManager()
 Clean up the plugin manager.
void LoadHandlersFromEnv(TEnv* env)
 Load plugin handlers specified in config file, like:
    Plugin.TFile:       ^rfio:    TRFIOFile      RFIO  "TRFIOFile(...)"
    Plugin.TSQLServer:  ^mysql:   TMySQLServer   MySQL "TMySQLServer(...)"
    +Plugin.TSQLServer: ^pgsql:   TPgSQLServer   PgSQL "TPgSQLServer(...)"
 The + allows the extension of an already defined resource (see TEnv).
void LoadHandlerMacros(const char* path)
 Load all plugin macros from the specified path/base directory.
void LoadHandlersFromPluginDirs(const char* base = 0)
 Load plugin handlers specified via macros in a list of plugin
 directories. The $ROOTSYS/etc/plugins is the default top plugin directory
 specified in $ROOTSYS/etc/system.rootrc. The macros must have names
 like <BaseClass>/PX0_<PluginClass>.C, e.g.:
    TFile/P10_TRFIOFile.C, TSQLServer/P20_TMySQLServer.C, etc.
 to allow easy sorting and grouping. If the BaseClass is in a namespace
 the directory must have the name NameSpace@@BaseClass as : is a reserved
 pathname character on some operating systems. Macros not beginning with
 'P' and ending with ".C" are ignored. If base is specified only plugin
 macros for that base class are loaded. The macros typically
 should look like:
   void P10_TDCacheFile()
   {
       gPluginMgr->AddHandler("TFile", "^dcache", "TDCacheFile",
          "DCache", "TDCacheFile(const char*,Option_t*,const char*,Int_t)");
   }
 In general these macros should not cause side effects, by changing global
 ROOT state via, e.g. gSystem calls, etc. However, in specific cases
 this might be useful, e.g. adding a library search path, adding a specific
 dependency, check on some OS or ROOT capability or downloading
 of the plugin.
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. If there is already a
 handler defined for the same base and regexp it will be replaced.
void RemoveHandler(const char* base, const char* regexp = 0)
 Remove handler for the specified base class and the specified
 regexp. If regexp=0 remove all handlers for the specified base.
TPluginHandler * FindHandler(const char* base, const char* uri = 0)
 Returns the handler if there exists a handler for the specified URI.
 The uri can be 0 in which case the first matching plugin handler
 will be returned. Returns 0 in case handler is not found.
void Print(Option_t* opt = "") const
 Print list of registered plugin handlers. If option is "a" print
 also the ctor's that will be used.
Int_t WritePluginMacros(const char* dir, const char* plugin = 0) const
 Write in the specified directory the plugin macros. If plugin is specified
 and if it is a base class all macros for that base will be written. If it
 is a plugin class name, only that one macro will be written. If plugin
 is 0 all macros are written. Returns -1 if dir does not exist, 0 otherwise.
TPluginHandler& operator=(const TPluginManager& pm)
TPluginManager(const TPluginManager& pm)
TPluginManager()
{ }