|
||||
File indexing completed on 2024-11-15 10:00:59
0001 #ifndef __XRDOUCPINLOADER_HH__ 0002 #define __XRDOUCPINLOADER_HH__ 0003 /******************************************************************************/ 0004 /* */ 0005 /* X r d O u c P i n L o a d e r . h h */ 0006 /* */ 0007 /* (c) 2014 by the Board of Trustees of the Leland Stanford, Jr., University */ 0008 /* Produced by Andrew Hanushevsky for Stanford University under contract */ 0009 /* DE-AC02-76-SFO0515 with the Department of Energy */ 0010 /* */ 0011 /* This file is part of the XRootD software suite. */ 0012 /* */ 0013 /* XRootD is free software: you can redistribute it and/or modify it under */ 0014 /* the terms of the GNU Lesser General Public License as published by the */ 0015 /* Free Software Foundation, either version 3 of the License, or (at your */ 0016 /* option) any later version. */ 0017 /* */ 0018 /* XRootD is distributed in the hope that it will be useful, but WITHOUT */ 0019 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */ 0020 /* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */ 0021 /* License for more details. */ 0022 /* */ 0023 /* You should have received a copy of the GNU Lesser General Public License */ 0024 /* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */ 0025 /* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */ 0026 /* */ 0027 /* The copyright holder's institutional names and contributor's names may not */ 0028 /* be used to endorse or promote products derived from this software without */ 0029 /* specific prior written permission of the institution or contributor. */ 0030 /******************************************************************************/ 0031 0032 //------------------------------------------------------------------------------ 0033 //! This include file define a class that loads a versioned plugin. 0034 //------------------------------------------------------------------------------ 0035 0036 //------------------------------------------------------------------------------ 0037 //! Load a plugin. Internal plugin version checking is performed when the 0038 //! plugin is actually initialized by the caller. The caller is responsible 0039 //! for persisting the image after initializing the plugin. 0040 //! 0041 //! @return !0 Pointer to the successfully loaded. 0042 //! @return =0 The plugin could not be loaded. 0043 //------------------------------------------------------------------------------ 0044 0045 class XrdSysError; 0046 class XrdSysPlugin; 0047 struct XrdVersionInfo; 0048 0049 class XrdOucPinLoader 0050 { 0051 public: 0052 0053 //------------------------------------------------------------------------------ 0054 //! Export the plugin object for manual management. 0055 //! 0056 //! @return !0 Pointer to the plugin object. It is disassociated from this 0057 //! object and must be manually managed. 0058 //! @return =0 Either no plugin object has been created or it has been 0059 //! exported. 0060 //------------------------------------------------------------------------------ 0061 0062 XrdSysPlugin *Export() {XrdSysPlugin *tmp = piP; piP = 0; return tmp;} 0063 0064 //------------------------------------------------------------------------------ 0065 //! Set export range of symbols in the plugin. 0066 //! 0067 //! @param glbl when true then the symbols defined in the plug-in shared 0068 //! library are made available for symbol resolution of 0069 //! subsequently loaded libraries. 0070 //------------------------------------------------------------------------------ 0071 0072 void Global(bool glbl) {global = glbl;} 0073 0074 //------------------------------------------------------------------------------ 0075 //! Get the last message placed in the buffer. 0076 //! 0077 //! @return Pointer to the last message. If there is no buffer or no message 0078 //! exists, a null string is returned. 0079 //------------------------------------------------------------------------------ 0080 0081 const char *LastMsg() {return (errBP ? errBP : "");} 0082 0083 //------------------------------------------------------------------------------ 0084 //! Get the actual path that was or will tried for loading. 0085 //! 0086 //! @return Pointer to the path that was loaded if called after Resolve() 0087 //! or the path that will be attempted to be loaded. If the 0088 //! path is invalid, a single question mark is returned. 0089 //------------------------------------------------------------------------------ 0090 0091 const char *Path() {return theLib;} 0092 0093 //------------------------------------------------------------------------------ 0094 //! Resolve a desired symbol from the plugin image. 0095 //! 0096 //! @param symbl Pointer to the name of the symbol to resolve. 0097 //! @param mcnt Maximum number of version messages to be displayed. 0098 //! 0099 //! @return !0 The address of the symbol. 0100 //! @return =0 The symbol could not be resolved. 0101 //------------------------------------------------------------------------------ 0102 0103 void *Resolve(const char *symbl, int mcnt=1); 0104 0105 //------------------------------------------------------------------------------ 0106 //! Unload any plugin that may be associated with this object. The plugin image 0107 //! will not be persisted when this object is deleted. 0108 //! 0109 //! @param dodel When true, the object is deleted (this only works if it is 0110 //! created via new). Otherwise, plugin is only unloaded. 0111 //------------------------------------------------------------------------------ 0112 0113 void Unload(bool dodel=false); 0114 0115 //------------------------------------------------------------------------------ 0116 //! Constructor #1 0117 //! 0118 //! @param errP Pointer to the message routing object. 0119 //! @param vInfo Pointer to the version information of the caller. If the 0120 //! pointer is nil, no version checking occurs. 0121 //! @param drctv Pointer to the directive that initiated the load. The text is 0122 //! used in error messages to relate the directive to the error. 0123 //! E.g. "ofs.osslib" -> "Unable to load ofs.osslib plugin...." 0124 //! @param plib Pointer to the shared library path that contains the plugin. 0125 //------------------------------------------------------------------------------ 0126 0127 XrdOucPinLoader(XrdSysError *errP, 0128 XrdVersionInfo *vInfo, 0129 const char *drctv, 0130 const char *plib); 0131 0132 //------------------------------------------------------------------------------ 0133 //! Constructor #2 0134 //! 0135 //! @param eBuff Pointer to a buffer to receive messages. 0136 //! @param eBlen Length of the buffer. 0137 //! @param vInfo Pointer to the version information of the caller. If the 0138 //! pointer is nil, no version checking occurs. 0139 //! @param drctv Pointer to the directive that initiated the load (see above). 0140 //! @param plib Pointer to the shared library path that contains the plugin. 0141 //------------------------------------------------------------------------------ 0142 0143 XrdOucPinLoader(char *eBuff, 0144 int eBlen, 0145 XrdVersionInfo *vInfo, 0146 const char *drctv, 0147 const char *plib); 0148 0149 //------------------------------------------------------------------------------ 0150 //! Constructor #3 (An internal message buffer is allocated. You can get the 0151 //! message, if any, using LastMsg()) 0152 //! 0153 //! @param vInfo Pointer to the version information of the caller. If the 0154 //! pointer is nil, no version checking occurs. 0155 //! @param drctv Pointer to the directive that initiated the load (see above). 0156 //! @param plib Pointer to the shared library path that contains the plugin. 0157 //------------------------------------------------------------------------------ 0158 0159 XrdOucPinLoader(XrdVersionInfo *vInfo, 0160 const char *drctv, 0161 const char *plib); 0162 0163 //------------------------------------------------------------------------------ 0164 //! Destructor 0165 //! 0166 //! Upon deletion, if the plugin was successfully loaded, it is persisted. 0167 //------------------------------------------------------------------------------ 0168 0169 ~XrdOucPinLoader(); 0170 0171 private: 0172 void Inform(const char *txt1, const char *txt2=0, 0173 const char *txt3=0, const char *txt4=0, 0174 const char *txt5=0); 0175 void Init(const char *drctv, const char *plib); 0176 bool LoadLib(int mcnt); 0177 0178 XrdSysError *eDest; 0179 XrdSysPlugin *piP; 0180 XrdVersionInfo *viP; 0181 const char *dName; 0182 char *theLib; 0183 char *altLib; 0184 char *errBP; 0185 int errBL; 0186 bool global; 0187 bool frBuff; 0188 bool badLib; 0189 }; 0190 #endif
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |