00001 #ifndef __XRDOUCCACHE2_HH__ 00002 #define __XRDOUCCACHE2_HH__ 00003 /******************************************************************************/ 00004 /* */ 00005 /* X r d O u c C a c h e 2 . h h */ 00006 /* */ 00007 /* (c) 2016 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 /* This file is part of the XRootD software suite. */ 00013 /* */ 00014 /* XRootD is free software: you can redistribute it and/or modify it under */ 00015 /* the terms of the GNU Lesser General Public License as published by the */ 00016 /* Free Software Foundation, either version 3 of the License, or (at your */ 00017 /* option) any later version. */ 00018 /* */ 00019 /* XRootD is distributed in the hope that it will be useful, but WITHOUT */ 00020 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */ 00021 /* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */ 00022 /* License for more details. */ 00023 /* */ 00024 /* You should have received a copy of the GNU Lesser General Public License */ 00025 /* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */ 00026 /* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */ 00027 /* */ 00028 /* The copyright holder's institutional names and contributor's names may not */ 00029 /* be used to endorse or promote products derived from this software without */ 00030 /* specific prior written permission of the institution or contributor. */ 00031 /******************************************************************************/ 00032 00033 #include <errno.h> 00034 00035 #include "XrdOuc/XrdOucCache.hh" 00036 00037 //----------------------------------------------------------------------------- 00050 //----------------------------------------------------------------------------- 00051 00052 /******************************************************************************/ 00053 /* C l a s s X r d O u c C a c h e I O 2 */ 00054 /******************************************************************************/ 00055 00056 //------------------------------------------------------------------------------ 00060 //------------------------------------------------------------------------------ 00061 00062 class XrdOucCacheIO2 : public virtual XrdOucCacheIO 00063 { 00064 public: 00065 00066 //------------------------------------------------------------------------------ 00077 //------------------------------------------------------------------------------ 00078 00079 virtual int Fstat(struct stat &sbuff) {(void)sbuff; return 1;} 00080 00081 //----------------------------------------------------------------------------- 00086 //----------------------------------------------------------------------------- 00087 virtual 00088 const char *Location() {return "";} 00089 00090 //------------------------------------------------------------------------------ 00103 //------------------------------------------------------------------------------ 00104 00105 using XrdOucCacheIO::Read; 00106 00107 virtual void Read (XrdOucCacheIOCB &iocb, char *buff, long long offs, int rlen) 00108 {iocb.Done(Read(buff, offs, rlen));} 00109 00110 //------------------------------------------------------------------------------ 00121 //------------------------------------------------------------------------------ 00122 00123 using XrdOucCacheIO::ReadV; 00124 00125 virtual void ReadV(XrdOucCacheIOCB &iocb, const XrdOucIOVec *readV, int rnum) 00126 {iocb.Done(ReadV(readV, rnum));} 00127 00128 //------------------------------------------------------------------------------ 00137 //------------------------------------------------------------------------------ 00138 00139 using XrdOucCacheIO::Sync; 00140 00141 virtual void Sync(XrdOucCacheIOCB &iocb) {iocb.Done(Sync());} 00142 00143 //------------------------------------------------------------------------------ 00153 //------------------------------------------------------------------------------ 00154 00155 virtual void Update(XrdOucCacheIO2 &iocp) {} 00156 00157 //------------------------------------------------------------------------------ 00170 //------------------------------------------------------------------------------ 00171 00172 using XrdOucCacheIO::Write; 00173 00174 virtual void Write(XrdOucCacheIOCB &iocb, char *buff, long long offs, int wlen) 00175 {iocb.Done(Write(buff, offs, wlen));} 00176 00177 //------------------------------------------------------------------------------ 00178 00179 virtual ~XrdOucCacheIO2() {} // Always use Detach() instead of direct delete! 00180 }; 00181 00182 /******************************************************************************/ 00183 /* C l a s s X r d O u c C a c h e 2 */ 00184 /******************************************************************************/ 00185 00186 class XrdOucEnv; 00187 struct stat; 00188 00189 //------------------------------------------------------------------------------ 00194 //------------------------------------------------------------------------------ 00195 00196 class XrdOucCache2 : public virtual XrdOucCache 00197 { 00198 public: 00199 00200 //------------------------------------------------------------------------------ 00214 //------------------------------------------------------------------------------ 00215 00216 using XrdOucCache::Attach; 00217 00218 virtual 00219 XrdOucCacheIO2 *Attach(XrdOucCacheIO2 *ioP, int opts=0) = 0; 00220 00221 virtual 00222 XrdOucCacheIO *Attach(XrdOucCacheIO *ioP, int opts=0) 00223 {errno = ENOSYS; return ioP;} 00224 00225 //------------------------------------------------------------------------------ 00231 //------------------------------------------------------------------------------ 00232 virtual 00233 XrdOucCache *Create(Parms &Params, XrdOucCacheIO::aprParms *aprP=0) 00234 {return this;} 00235 00236 //------------------------------------------------------------------------------ 00247 //------------------------------------------------------------------------------ 00248 virtual 00249 void EnvInfo(XrdOucEnv &theEnv) {(void)theEnv;} 00250 00251 //------------------------------------------------------------------------------ 00295 //------------------------------------------------------------------------------ 00296 00297 enum LFP_Reason {ForAccess=0, ForInfo, ForPath}; 00298 00299 virtual 00300 int LocalFilePath(const char *url, char *buff=0, int blen=0, 00301 LFP_Reason why=ForAccess, bool forall=false) 00302 {(void)url; (void)buff; (void)blen; (void)why; 00303 if (buff && blen > 0) *buff = 0; 00304 return -ENOTSUP; 00305 } 00306 00307 //------------------------------------------------------------------------------ 00323 //------------------------------------------------------------------------------ 00324 virtual 00325 int Prepare(const char *url, int oflags, mode_t mode) 00326 {(void)url; (void)oflags; (void)mode; return 0;} 00327 00328 //------------------------------------------------------------------------------ 00340 //------------------------------------------------------------------------------ 00341 00342 virtual int Stat(const char *url, struct stat &sbuff) 00343 {(void)url; (void)sbuff; return 1;} 00344 00345 XrdOucCache2() {} 00346 virtual ~XrdOucCache2() {} 00347 }; 00348 00349 /******************************************************************************/ 00350 /* C r e a t i n g C a c h e P l u g - I n s */ 00351 /******************************************************************************/ 00352 00353 //------------------------------------------------------------------------------ 00382 #endif