XRootD
XrdCksCalc.hh
Go to the documentation of this file.
1 #ifndef __XRDCKSCALC_HH__
2 #define __XRDCKSCALC_HH__
3 /******************************************************************************/
4 /* */
5 /* X r d C k s C a l c . h h */
6 /* */
7 /* (c) 2011 by the Board of Trustees of the Leland Stanford, Jr., University */
8 /* All Rights Reserved */
9 /* Produced by Andrew Hanushevsky for Stanford University under contract */
10 /* DE-AC02-76-SFO0515 with the Department of Energy */
11 /* */
12 /* This file is part of the XRootD software suite. */
13 /* */
14 /* XRootD is free software: you can redistribute it and/or modify it under */
15 /* the terms of the GNU Lesser General Public License as published by the */
16 /* Free Software Foundation, either version 3 of the License, or (at your */
17 /* option) any later version. */
18 /* */
19 /* XRootD is distributed in the hope that it will be useful, but WITHOUT */
20 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
21 /* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */
22 /* License for more details. */
23 /* */
24 /* You should have received a copy of the GNU Lesser General Public License */
25 /* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */
26 /* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */
27 /* */
28 /* The copyright holder's institutional names and contributor's names may not */
29 /* be used to endorse or promote products derived from this software without */
30 /* specific prior written permission of the institution or contributor. */
31 /******************************************************************************/
32 
40 {
41 public:
42 
43 //------------------------------------------------------------------------------
52 //------------------------------------------------------------------------------
53 
54 virtual char *Calc(const char *Buff, int BLen)
55  {Init(); Update(Buff, BLen); return Final();}
56 
57 //------------------------------------------------------------------------------
65 //------------------------------------------------------------------------------
66 
67 virtual bool Combinable() {return false;}
68 
69 //------------------------------------------------------------------------------
82 //------------------------------------------------------------------------------
83 
84 virtual
85 const char* Combine(const char *Cksum, int DLen) {return 0;};
86 
87 //------------------------------------------------------------------------------
101 //------------------------------------------------------------------------------
102 
103 virtual
104 const char* Combine(const char* Cksum1, const char* Cksum2, int DLen)
105  {return 0;};
106 
107 //------------------------------------------------------------------------------
113 //------------------------------------------------------------------------------
114 
115 virtual char *Current() {return Final();}
116 
117 //------------------------------------------------------------------------------
122 //------------------------------------------------------------------------------
123 
124 virtual char *Final() = 0;
125 
126 //------------------------------------------------------------------------------
129 //------------------------------------------------------------------------------
130 
131 virtual void Init() = 0;
132 
133 //------------------------------------------------------------------------------
137 //------------------------------------------------------------------------------
138 virtual
140 
141 //------------------------------------------------------------------------------
143 //------------------------------------------------------------------------------
144 
145 virtual void Recycle() {delete this;}
146 
147 //------------------------------------------------------------------------------
155 //------------------------------------------------------------------------------
156 
157 virtual const char *Type(int &csSize) = 0;
158 
159 //------------------------------------------------------------------------------
165 //------------------------------------------------------------------------------
166 
167 virtual void Update(const char *Buff, int BLen) = 0;
168 
169 //------------------------------------------------------------------------------
171 //------------------------------------------------------------------------------
172 
174 
175 //------------------------------------------------------------------------------
177 //------------------------------------------------------------------------------
178 
179 virtual ~XrdCksCalc() {}
180 };
181 
182 /******************************************************************************/
183 /* C h e c k s u m O b j e c t C r e a t o r */
184 /******************************************************************************/
185 
186 //------------------------------------------------------------------------------
200 //------------------------------------------------------------------------------
201 
208 //------------------------------------------------------------------------------
214 //------------------------------------------------------------------------------
215 
221 #endif
virtual char * Final()=0
virtual bool Combinable()
Definition: XrdCksCalc.hh:67
virtual void Update(const char *Buff, int BLen)=0
virtual char * Calc(const char *Buff, int BLen)
Definition: XrdCksCalc.hh:54
virtual const char * Combine(const char *Cksum, int DLen)
Definition: XrdCksCalc.hh:85
virtual const char * Type(int &csSize)=0
virtual char * Current()
Definition: XrdCksCalc.hh:115
virtual void Recycle()
Recycle the checksum object as it is no longer needed. A default is given.
Definition: XrdCksCalc.hh:145
virtual void Init()=0
virtual const char * Combine(const char *Cksum1, const char *Cksum2, int DLen)
Definition: XrdCksCalc.hh:104
virtual XrdCksCalc * New()=0
virtual ~XrdCksCalc()
Destructor.
Definition: XrdCksCalc.hh:179
XrdCksCalc()
Constructor.
Definition: XrdCksCalc.hh:173