|
xrootd
|
00001 #ifndef __XRDCKSCALC_HH__ 00002 #define __XRDCKSCALC_HH__ 00003 /******************************************************************************/ 00004 /* */ 00005 /* X r d C k s C a l c . h h */ 00006 /* */ 00007 /* (c) 2011 by the Board of Trustees of the Leland Stanford, Jr., University */ 00008 /* All Rights Reserved */ 00009 /* Produced by Andrew Hanushevsky for Stanford University under contract */ 00010 /* DE-AC02-76-SFO0515 with the Department of Energy */ 00011 /******************************************************************************/ 00012 00013 // This class defines the interface to a checksum computation. When this class 00014 // is used to define a plugin computation, the initial XrdCksCalc computation object 00015 // is created by the XrdCksCalcInit() function defined at the end of this file. 00016 00017 class XrdCksCalc 00018 { 00019 public: 00020 00021 // Calc() Calculates a one-time checksum. The obvious default implementation 00022 // is provided and assumes that Init() may be called more than once. 00023 // 00024 virtual char *Calc(const char *Buff, int BLen) 00025 {Init(); Update(Buff, BLen); return Final();} 00026 00027 // Current() returns the current binary checksum value (defaults to final). 00028 // The final checksum result is not affected. 00029 // 00030 virtual char *Current() {return Final();} 00031 00032 // Final() Returns the actual checksum in binary format. 00033 // 00034 virtual char *Final() = 0; 00035 00036 // Init() Initializes data structures (must be called by constructor). This 00037 // is always called to reuse the object for a new checksum. 00038 // 00039 virtual void Init() = 0; 00040 00041 // New() Must provide a new instance of the underlying object. 00042 // 00043 virtual 00044 XrdCksCalc *New() = 0; 00045 00046 // Recycle() Is called when the object is no longer needed. A default is given. 00047 // 00048 virtual void Recycle() {delete this;} 00049 00050 // Type() returns the character name of the checksum object and the number 00051 // bytes (i.e. size) required for the checksum value. 00052 // 00053 virtual const char *Type(int &csSize) = 0; 00054 00055 // Update() computes a running checksum and may be called repeatedly for 00056 // data segments; with Final() returning the full checksum. 00057 // 00058 virtual void Update(const char *Buff, int BLen) = 0; 00059 00060 XrdCksCalc() {} 00061 virtual ~XrdCksCalc() {} 00062 }; 00063 00064 /******************************************************************************/ 00065 /* C h e c k s u m O b j e c t C r e a t o r */ 00066 /******************************************************************************/ 00067 00068 /* When building a shared library plugin, the following "C" entry point must 00069 exist in the library: 00070 00071 extern "C" 00072 {XrdCksCalc *XrdCksCalcInit(XrdSysError *eDest, // The error msg object 00073 const char *csName, // Name of checksum 00074 const char *cFN, // Config file name 00075 const char *Parms); // Parms on lib directive 00076 } 00077 00078 This entry is called to get an instance of the checksum object which must 00079 match the passed checksum name. If the object cannot be created; return 0. 00080 */ 00081 #endif
1.7.5