|
|
|||
File indexing completed on 2026-01-08 10:33:35
0001 #ifndef __XRDCKSCALC_HH__ 0002 #define __XRDCKSCALC_HH__ 0003 /******************************************************************************/ 0004 /* */ 0005 /* X r d C k s C a l c . h h */ 0006 /* */ 0007 /* (c) 2011 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 /*! This class defines the interface to a checksum computation. When this class 0034 is used to define a plugin computation, the initial XrdCksCalc computation 0035 object is created by the XrdCksCalcInit() function defined at the end of 0036 this file. 0037 */ 0038 0039 class XrdCksCalc 0040 { 0041 public: 0042 0043 //------------------------------------------------------------------------------ 0044 //! Calculate a one-time checksum. The obvious default implementation is 0045 //! provided and assumes that Init() may be called more than once. 0046 //! 0047 //! @param Buff -> Data to be checksummed. 0048 //! @param BLen -> Length of the data in Buff. 0049 //! 0050 //! @return the checksum value in binary format. The pointer to the value 0051 //! becomes invalid once the associated object is deleted. 0052 //------------------------------------------------------------------------------ 0053 0054 virtual char *Calc(const char *Buff, int BLen) 0055 {Init(); Update(Buff, BLen); return Final();} 0056 0057 //------------------------------------------------------------------------------ 0058 //! Get the current binary checksum value (defaults to final). However, the 0059 //! final checksum result is not affected. 0060 //! 0061 //! @return the checksum value in binary format. The pointer to the value 0062 //! becomes invalid once the associated object is deleted. 0063 //------------------------------------------------------------------------------ 0064 0065 virtual char *Current() {return Final();} 0066 0067 //------------------------------------------------------------------------------ 0068 //! Get the actual checksum in binary format. 0069 //! 0070 //! @return the checksum value in binary format. The pointer to the value 0071 //! becomes invalid once the associated object is deleted. 0072 //------------------------------------------------------------------------------ 0073 0074 virtual char *Final() = 0; 0075 0076 //------------------------------------------------------------------------------ 0077 //! Initializes data structures (must be called by constructor). This is always 0078 //! called to reuse the object for a new checksum. 0079 //------------------------------------------------------------------------------ 0080 0081 virtual void Init() = 0; 0082 0083 //------------------------------------------------------------------------------ 0084 //! Get a new instance of the underlying checksum calculation object. 0085 //! 0086 //! @return the checksum calculation object. 0087 //------------------------------------------------------------------------------ 0088 virtual 0089 XrdCksCalc *New() = 0; 0090 0091 //------------------------------------------------------------------------------ 0092 //! Recycle the checksum object as it is no longer needed. A default is given. 0093 //------------------------------------------------------------------------------ 0094 0095 virtual void Recycle() {delete this;} 0096 0097 //------------------------------------------------------------------------------ 0098 //! Get the checksum object algorithm name and the number bytes (i.e. size) 0099 //! required for the checksum value. 0100 //! 0101 //! @param csSize -> Parameter to hold the size of the checksum value. 0102 //! 0103 //! @return the checksum algorithm's name. The name persists event after the 0104 //! checksum object is deleted. 0105 //------------------------------------------------------------------------------ 0106 0107 virtual const char *Type(int &csSize) = 0; 0108 0109 //------------------------------------------------------------------------------ 0110 //! Compute a running checksum. This method may be called repeatedly for data 0111 //! segments; with Final() returning the full checksum. 0112 //! 0113 //! @param Buff -> Data to be checksummed. 0114 //! @param BLen -> Length of the data in Buff. 0115 //------------------------------------------------------------------------------ 0116 0117 virtual void Update(const char *Buff, int BLen) = 0; 0118 0119 //------------------------------------------------------------------------------ 0120 //! Constructor 0121 //------------------------------------------------------------------------------ 0122 0123 XrdCksCalc() {} 0124 0125 //------------------------------------------------------------------------------ 0126 //! Destructor 0127 //------------------------------------------------------------------------------ 0128 0129 virtual ~XrdCksCalc() {} 0130 }; 0131 0132 /******************************************************************************/ 0133 /* C h e c k s u m O b j e c t C r e a t o r */ 0134 /******************************************************************************/ 0135 0136 //------------------------------------------------------------------------------ 0137 //! Obtain an instance of the checksum calculation object. 0138 //! 0139 //! XrdCksCalcInit() is an extern "C" function that is called to obtain an 0140 //! initial instance of a checksum calculation object. You may create custom 0141 //! checksum calculation and use them as plug-ins to the checksum manager 0142 //! (see XrdCks.hh). The function must be defined in the plug-in shared library. 0143 //! All the following extern symbols must be defined at file level! 0144 //! 0145 //! @param eDest -> The XrdSysError object for messages. 0146 //! @param csName -> The name of the checksum algorithm. 0147 //! @param cFN -> The name of the configuration file 0148 //! @param Parms -> Parameters specified on the ckslib directive. If none it is 0149 //! zero. 0150 //------------------------------------------------------------------------------ 0151 0152 /*! extern "C" XrdCksCalc *XrdCksCalcInit(XrdSysError *eDest, 0153 const char *csName, 0154 const char *cFN, 0155 const char *Parms); 0156 */ 0157 0158 //------------------------------------------------------------------------------ 0159 //! Declare the compilation version number. 0160 //! 0161 //! Additionally, you *should* declare the xrootd version you used to compile 0162 //! your plug-in. While not currently required, it is highly recommended to 0163 //! avoid execution issues should the class definition change. Declare it as: 0164 //------------------------------------------------------------------------------ 0165 0166 /*! #include "XrdVersion.hh" 0167 XrdVERSIONINFO(XrdCksCalcInit,<name>); 0168 0169 where <name> is a 1- to 15-character unquoted name identifying your plugin. 0170 */ 0171 #endif
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|