Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 10:27:55

0001 #ifndef __XRDOUCNAME2NAME_H__
0002 #define __XRDOUCNAME2NAME_H__
0003 /******************************************************************************/
0004 /*                                                                            */
0005 /*                    X r d O u c n a m e 2 n a m e . h h                     */
0006 /*                                                                            */
0007 /* (c) 2006 by the Board of Trustees of the Leland Stanford, Jr., University  */
0008 /*                            All Rights Reserved                             */
0009 /*   Produced by Andrew Hanushevsky for Stanford University under contract    */
0010 /*              DE-AC02-76-SFO0515 with the Department of Energy              */
0011 /*                                                                            */
0012 /* This file is part of the XRootD software suite.                            */
0013 /*                                                                            */
0014 /* XRootD is free software: you can redistribute it and/or modify it under    */
0015 /* the terms of the GNU Lesser General Public License as published by the     */
0016 /* Free Software Foundation, either version 3 of the License, or (at your     */
0017 /* option) any later version.                                                 */
0018 /*                                                                            */
0019 /* XRootD is distributed in the hope that it will be useful, but WITHOUT      */
0020 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or      */
0021 /* FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public       */
0022 /* License for more details.                                                  */
0023 /*                                                                            */
0024 /* You should have received a copy of the GNU Lesser General Public License   */
0025 /* along with XRootD in a file called COPYING.LESSER (LGPL license) and file  */
0026 /* COPYING (GPL license).  If not, see <http://www.gnu.org/licenses/>.        */
0027 /*                                                                            */
0028 /* The copyright holder's institutional names and contributor's names may not */
0029 /* be used to endorse or promote products derived from this software without  */
0030 /* specific prior written permission of the institution or contributor.       */
0031 /******************************************************************************/
0032 
0033 #include <string>
0034 #include <vector>
0035 
0036 /******************************************************************************/
0037 /*                       X r d O u c N a m e 2 N a m e                        */
0038 /******************************************************************************/
0039 
0040 //! Class XrdoucName2Name must be used for creating a name translation plug-in.
0041 //! This plug-in is specified by the 'oss.namelib' directive and when present
0042 //! makes the default oss plug-in load the plug-in shared library, locate the
0043 //! XrdOucgetName2Name function within and use it to obtain an instance of the
0044 //! XrdOucName2Name object to perform name translation prior to all subsequent
0045 //! storage system calls. The companion object, XrdOucName2NameVec, should
0046 //! also be defined in the same shared library (see the class definition below).
0047   
0048 class XrdOucName2Name
0049 {
0050 public:
0051 
0052 //------------------------------------------------------------------------------
0053 //! Map a logical file name to a physical file name.
0054 //!
0055 //! @param  lfn   -> Logical file name.
0056 //! @param  buff  -> Buffer where the physical file name of an existing file is
0057 //!                  to be placed. It must end with a null byte.
0058 //! @param  blen     The length of the buffer.
0059 //!
0060 //! @return Success: Zero.
0061 //!         Failure: An errno number describing the failure; typically
0062 //!                  EINVAL       - The supplied lfn is invalid.
0063 //!                  ENAMETOOLONG - The buffer is too small for the pfn.
0064 //------------------------------------------------------------------------------
0065 
0066 virtual int lfn2pfn(const char *lfn, char *buff, int blen) = 0;
0067 
0068 //------------------------------------------------------------------------------
0069 //! Map a logical file name to the name the file would have in a remote storage
0070 //! system (e.g. Mass Storage System at a remote location).
0071 //!
0072 //! @param  lfn   -> Logical file name.
0073 //! @param  buff  -> Buffer where the remote file name is to be placed. It need
0074 //!                  not actually exist in that location but could be created
0075 //!                  there with that name. It must end with a null byte.
0076 //! @param  blen     The length of the buffer.
0077 //!
0078 //! @return Success: Zero.
0079 //!         Failure: An errno number describing the failure; typically
0080 //!                  EINVAL       - The supplied lfn is invalid.
0081 //!                  ENAMETOOLONG - The buffer is too small for the pfn.
0082 //------------------------------------------------------------------------------
0083 
0084 virtual int lfn2rfn(const char *lfn, char *buff, int blen) = 0;
0085 
0086 //------------------------------------------------------------------------------
0087 //! Map a physical file name to it's logical file name.
0088 //!
0089 //! @param  pfn   -> Physical file name. This is always a valid name of either
0090 //!                  an existing file or a file that could been created.
0091 //! @param  buff  -> Buffer where the logical file name is to be placed. It need
0092 //!                  not actually exist but could be created with that name.
0093 //!                  It must end with a null byte.
0094 //! @param  blen     The length of the buffer.
0095 //!
0096 //! @return Success: Zero.
0097 //!         Failure: An errno number describing the failure; typically
0098 //!                  EINVAL       - The supplied lfn is invalid.
0099 //!                  ENAMETOOLONG - The buffer is too small for the pfn.
0100 //------------------------------------------------------------------------------
0101 
0102 virtual int pfn2lfn(const char *pfn, char *buff, int blen) = 0;
0103 
0104 //------------------------------------------------------------------------------
0105 //! Constructor
0106 //------------------------------------------------------------------------------
0107 
0108              XrdOucName2Name() {}
0109 
0110 //------------------------------------------------------------------------------
0111 //! Destructor
0112 //------------------------------------------------------------------------------
0113 
0114 virtual     ~XrdOucName2Name() {}
0115 };
0116 
0117 /******************************************************************************/
0118 /*                    X r d O u c N a m e 2 N a m e V e c                     */
0119 /******************************************************************************/
0120 
0121 //! Class XrdOucName2NameVec must be used to define a companion name translation
0122 //! mechanism. It is optional but highly recommended and may in fact be required
0123 //! by certain statlib plug-ins specific by the 'oss.statlib' directive. Refer
0124 //! to plug-in documentation to see if it requires this form of name2name
0125 //! translator. This translator should return all possible translations of a
0126 //! given logical file name. After an instance of the XrdOucName2Name
0127 //! translator is obtained (which implies it's full initilization) the default
0128 //! oss plug-in check if the symbol 'Name2NameVec' is present in the shared
0129 //! library. If it does, it obtains the contents of the symbol which should be
0130 //! a pointer to an object derived from the following class. That object is
0131 //! used to obtain a list of possible name translations. Initialization is
0132 //! is simplified if your implementation inherits XrdOucName2Name as well as
0133 //! XrdOucName2Namevec. The symbol that contains the pointer must be defined
0134 //! at file level as follows:
0135 
0136 //! XrdOucName2NameVec *Name2NameVec;
0137 
0138 //! It should be set during XrdOucName2Name initialization to point to an
0139 //! instance of the object. The methods defined for this class must be
0140 //! thread-safe. The default XrdOucName2Name translator also includes the
0141 //! XrdOucName2NameVec translator.
0142   
0143 class XrdOucName2NameVec
0144 {
0145 public:
0146 
0147 //------------------------------------------------------------------------------
0148 //! Map a logical file name to all of its possible physical file names.
0149 //!
0150 //! @param  lfn   -> Logical file name.
0151 //!
0152 //! @return Success: Pointer to a vector of strings of physical file names.
0153 //!         Failure: A nil pointer indicating that no translation exists.
0154 //------------------------------------------------------------------------------
0155 
0156 virtual std::vector<std::string *> *n2nVec(const char *lfn)=0;
0157 
0158 //------------------------------------------------------------------------------
0159 //! Release all storage occupied by the vector returned by n2nVec().
0160 //!
0161 //! @param  nvP   -> Vector returned by n2nVec().
0162 //------------------------------------------------------------------------------
0163 
0164 virtual void Recycle(std::vector<std::string *> *nvP)
0165                     {if (nvP)
0166                         {for (unsigned int i = 0; i < nvP->size(); i++)
0167                              {delete (*nvP)[i];}
0168                          delete nvP;
0169                         }
0170                     }
0171 
0172 //------------------------------------------------------------------------------
0173 //! Constructor and Destructor
0174 //------------------------------------------------------------------------------
0175 
0176              XrdOucName2NameVec() {}
0177 virtual     ~XrdOucName2NameVec() {}
0178 };
0179 
0180 /******************************************************************************/
0181 /*                    X r d O u c g e t N a m e 2 N a m e                     */
0182 /******************************************************************************/
0183   
0184 //------------------------------------------------------------------------------
0185 //! Obtain an instance of the XrdOucName2Name object.
0186 //!
0187 //! This extern "C" function is called when a shared library plug-in containing
0188 //! implementation of this class is loaded. It must exist in the shared library
0189 //! and must be thread-safe.
0190 //!
0191 //! @param  eDest -> The error object that must be used to print any errors or
0192 //!                  other messages (see XrdSysError.hh).
0193 //! @param  confg -> Name of the configuration file that was used. This pointer
0194 //!                  may be null though that would be impossible.
0195 //! @param  parms -> Argument string specified on the namelib directive. It may
0196 //!                  be null or point to a null string if no parms exist.
0197 //! @param  lroot -> The path specified by the localroot directive. It is a
0198 //!                  null pointer if the directive was not specified.
0199 //! @param  rroot -> The path specified by the remoteroot directive. It is a
0200 //!                  null pointer if the directive was not specified.
0201 //!
0202 //! @return Success: A pointer to an instance of the XrdOucName2Name object.
0203 //!         Failure: A null pointer which causes initialization to fail.
0204 //!
0205 //! The Name2Name object is used frequently in the course of opening files
0206 //! as well as other meta-file operations (e.g., stat(), rename(), etc.).
0207 //! The algorithms used by this object *must* be efficient and speedy;
0208 //! otherwise system performance will be severely degraded.
0209 //------------------------------------------------------------------------------
0210 
0211 class XrdSysError;
0212 
0213 #define XrdOucgetName2NameArgs XrdSysError       *eDest, \
0214                                const char        *confg, \
0215                                const char        *parms, \
0216                                const char        *lroot, \
0217                                const char        *rroot
0218 
0219 extern "C" XrdOucName2Name *XrdOucgetName2Name(XrdOucgetName2NameArgs);
0220 
0221 //------------------------------------------------------------------------------
0222 //! Declare compilation version.
0223 //!
0224 //! Additionally, you *should* declare the xrootd version you used to compile
0225 //! your plug-in. While not currently required, it is highly recommended to
0226 //! avoid execution issues should the class definition change. Declare it as:
0227 //------------------------------------------------------------------------------
0228 
0229 /*! #include "XrdVersion.hh"
0230     XrdVERSIONINFO(XrdOucgetName2Name,<name>);
0231 
0232     where <name> is a 1- to 15-character unquoted name identifying your plugin.
0233 */
0234 #endif