xrootd
XrdOucCache2.hh
Go to the documentation of this file.
1 #ifndef __XRDOUCCACHE2_HH__
2 #define __XRDOUCCACHE2_HH__
3 /******************************************************************************/
4 /* */
5 /* X r d O u c C a c h e 2 . h h */
6 /* */
7 /* (c) 2016 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 
33 #include <errno.h>
34 
35 #include "XrdOuc/XrdOucCache.hh"
36 
37 //-----------------------------------------------------------------------------
50 //-----------------------------------------------------------------------------
51 
52 /******************************************************************************/
53 /* C l a s s X r d O u c C a c h e I O 2 */
54 /******************************************************************************/
55 
56 //------------------------------------------------------------------------------
60 //------------------------------------------------------------------------------
61 
62 class XrdOucCacheIO2 : public virtual XrdOucCacheIO
63 {
64 public:
65 
66 //------------------------------------------------------------------------------
77 //------------------------------------------------------------------------------
78 
79 virtual int Fstat(struct stat &sbuff) {(void)sbuff; return 1;}
80 
81 //-----------------------------------------------------------------------------
86 //-----------------------------------------------------------------------------
87 virtual
88 const char *Location() {return "";}
89 
90 //------------------------------------------------------------------------------
103 //------------------------------------------------------------------------------
104 
105 using XrdOucCacheIO::Read;
106 
107 virtual void Read (XrdOucCacheIOCB &iocb, char *buff, long long offs, int rlen)
108  {iocb.Done(Read(buff, offs, rlen));}
109 
110 //------------------------------------------------------------------------------
121 //------------------------------------------------------------------------------
122 
124 
125 virtual void ReadV(XrdOucCacheIOCB &iocb, const XrdOucIOVec *readV, int rnum)
126  {iocb.Done(ReadV(readV, rnum));}
127 
128 //------------------------------------------------------------------------------
137 //------------------------------------------------------------------------------
138 
139 using XrdOucCacheIO::Sync;
140 
141 virtual void Sync(XrdOucCacheIOCB &iocb) {iocb.Done(Sync());}
142 
143 //------------------------------------------------------------------------------
153 //------------------------------------------------------------------------------
154 
155 virtual void Update(XrdOucCacheIO2 &iocp) {}
156 
157 //------------------------------------------------------------------------------
170 //------------------------------------------------------------------------------
171 
173 
174 virtual void Write(XrdOucCacheIOCB &iocb, char *buff, long long offs, int wlen)
175  {iocb.Done(Write(buff, offs, wlen));}
176 
177 //------------------------------------------------------------------------------
178 
179 virtual ~XrdOucCacheIO2() {} // Always use Detach() instead of direct delete!
180 };
181 
182 /******************************************************************************/
183 /* C l a s s X r d O u c C a c h e 2 */
184 /******************************************************************************/
185 
186 class XrdOucEnv;
187 struct stat;
188 
189 //------------------------------------------------------------------------------
194 //------------------------------------------------------------------------------
195 
196 class XrdOucCache2 : public virtual XrdOucCache
197 {
198 public:
199 
200 //------------------------------------------------------------------------------
214 //------------------------------------------------------------------------------
215 
216 using XrdOucCache::Attach;
217 
218 virtual
219 XrdOucCacheIO2 *Attach(XrdOucCacheIO2 *ioP, int opts=0) = 0;
220 
221 virtual
223  {errno = ENOSYS; return ioP;}
224 
225 //------------------------------------------------------------------------------
231 //------------------------------------------------------------------------------
232 virtual
234  {return this;}
235 
236 //------------------------------------------------------------------------------
247 //------------------------------------------------------------------------------
248 virtual
249 void EnvInfo(XrdOucEnv &theEnv) {(void)theEnv;}
250 
251 //------------------------------------------------------------------------------
291 //------------------------------------------------------------------------------
292 
294 
295 virtual
296 int LocalFilePath(const char *url, char *buff=0, int blen=0,
297  LFP_Reason why=ForAccess)
298  {(void)url; (void)buff; (void)blen; (void)why;
299  if (buff && blen > 0) *buff = 0;
300  return -ENOTSUP;
301  }
302 
303 //------------------------------------------------------------------------------
319 //------------------------------------------------------------------------------
320 virtual
321 int Prepare(const char *url, int oflags, mode_t mode)
322  {(void)url; (void)oflags; (void)mode; return 0;}
323 
324 //------------------------------------------------------------------------------
336 //------------------------------------------------------------------------------
337 
338 virtual int Stat(const char *url, struct stat &sbuff)
339  {(void)url; (void)sbuff; return 1;}
340 
342 virtual ~XrdOucCache2() {}
343 };
344 
345 /******************************************************************************/
346 /* C r e a t i n g C a c h e P l u g - I n s */
347 /******************************************************************************/
348 
349 //------------------------------------------------------------------------------
378 #endif
Definition: XrdOucCache2.hh:293
virtual XrdOucCacheIO * Attach(XrdOucCacheIO *ioP, int Options=0)=0
virtual void Write(XrdOucCacheIOCB &iocb, char *buff, long long offs, int wlen)
Definition: XrdOucCache2.hh:174
Definition: XrdOucCache2.hh:196
virtual ~XrdOucCacheIO2()
Definition: XrdOucCache2.hh:179
virtual void Update(XrdOucCacheIO2 &iocp)
Definition: XrdOucCache2.hh:155
virtual void EnvInfo(XrdOucEnv &theEnv)
Definition: XrdOucCache2.hh:249
Definition: XrdOucCache2.hh:293
Definition: XrdOucCache.hh:127
virtual int Read(char *Buffer, long long Offset, int Length)=0
virtual XrdOucCache * Create(Parms &Params, XrdOucCacheIO::aprParms *aprP=0)
Definition: XrdOucCache2.hh:233
virtual int Write(char *Buffer, long long Offset, int Length)=0
XrdOucCache2()
Definition: XrdOucCache2.hh:341
Definition: XrdOucCache2.hh:293
virtual int Fstat(struct stat &sbuff)
Definition: XrdOucCache2.hh:79
virtual void ReadV(XrdOucCacheIOCB &iocb, const XrdOucIOVec *readV, int rnum)
Definition: XrdOucCache2.hh:125
virtual XrdOucCacheIO2 * Attach(XrdOucCacheIO2 *ioP, int opts=0)=0
Definition: XrdOucCache.hh:282
virtual void Sync(XrdOucCacheIOCB &iocb)
Definition: XrdOucCache2.hh:141
Definition: XrdOucCache2.hh:62
virtual int Stat(const char *url, struct stat &sbuff)
Definition: XrdOucCache2.hh:338
virtual XrdOucCacheIO * Attach(XrdOucCacheIO *ioP, int opts=0)
Definition: XrdOucCache2.hh:222
virtual int ReadV(const XrdOucIOVec *readV, int n)
Definition: XrdOucCache.hh:160
Definition: XrdOucEnv.hh:41
Definition: XrdOucIOVec.hh:40
virtual int LocalFilePath(const char *url, char *buff=0, int blen=0, LFP_Reason why=ForAccess)
Definition: XrdOucCache2.hh:296
Definition: XrdOucCache.hh:247
virtual void Read(XrdOucCacheIOCB &iocb, char *buff, long long offs, int rlen)
Definition: XrdOucCache2.hh:107
Definition: XrdOucCache.hh:93
#define stat(a, b)
Definition: XrdPosix.hh:96
virtual int Sync()=0
virtual ~XrdOucCache2()
Definition: XrdOucCache2.hh:342
LFP_Reason
Definition: XrdOucCache2.hh:293
virtual const char * Location()
Definition: XrdOucCache2.hh:88
Definition: XrdOucCache.hh:320
virtual int Prepare(const char *url, int oflags, mode_t mode)
Definition: XrdOucCache2.hh:321
virtual void Done(int result)=0