00001 #ifndef __SSI_SHMAT__ 00002 #define __SSI_SHMAT__ 00003 /******************************************************************************/ 00004 /* */ 00005 /* X r d S s i S h M a t . h h */ 00006 /* */ 00007 /* (c) 2015 by the Board of Trustees of the Leland Stanford, Jr., University */ 00008 /* Produced by Andrew Hanushevsky for Stanford University under contract */ 00009 /* DE-AC02-76-SFO0515 with the Department of Energy */ 00010 /* */ 00011 /* This file is part of the XRootD software suite. */ 00012 /* */ 00013 /* XRootD is free software: you can redistribute it and/or modify it under */ 00014 /* the terms of the GNU Lesser General Public License as published by the */ 00015 /* Free Software Foundation, either version 3 of the License, or (at your */ 00016 /* option) any later version. */ 00017 /* */ 00018 /* XRootD is distributed in the hope that it will be useful, but WITHOUT */ 00019 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */ 00020 /* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */ 00021 /* License for more details. */ 00022 /* */ 00023 /* You should have received a copy of the GNU Lesser General Public License */ 00024 /* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */ 00025 /* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */ 00026 /* */ 00027 /* The copyright holder's institutional names and contributor's names may not */ 00028 /* be used to endorse or promote products derived from this software without */ 00029 /* specific prior written permission of the institution or contributor. */ 00030 /******************************************************************************/ 00031 00032 #include <stdlib.h> 00033 #include <string.h> 00034 00035 //----------------------------------------------------------------------------- 00039 //----------------------------------------------------------------------------- 00040 00041 class XrdSsiShMat 00042 { 00043 public: 00044 00045 //----------------------------------------------------------------------------- 00061 //----------------------------------------------------------------------------- 00062 00063 virtual bool AddItem(void *newdata, void *olddata, const char *key, 00064 int hash=0, bool replace=false) = 0; 00065 00066 //----------------------------------------------------------------------------- 00082 //----------------------------------------------------------------------------- 00083 00084 virtual bool Attach(int tout, bool isrw=false) = 0; 00085 00086 //----------------------------------------------------------------------------- 00097 //----------------------------------------------------------------------------- 00098 00099 struct CRZParms 00100 {int indexSz; 00101 int maxKeys; 00102 int maxKLen; 00103 int mode; 00104 signed char multW; 00108 signed char reUse; 00112 char rsvd[6]; 00113 00114 CRZParms() : indexSz(0), maxKeys(0), maxKLen(0), mode(0640), 00115 multW(-1), reUse(-1) 00116 {memset(rsvd, -1, sizeof(rsvd));} 00117 ~CRZParms() {} 00118 }; 00119 00120 virtual bool Create(CRZParms &parms) = 0; 00121 00122 //----------------------------------------------------------------------------- 00127 //----------------------------------------------------------------------------- 00128 00129 virtual bool Export() = 0; 00130 00131 //----------------------------------------------------------------------------- 00145 //----------------------------------------------------------------------------- 00146 00147 virtual bool DelItem(void *data, const char *key, int hash=0) = 0; 00148 00149 //----------------------------------------------------------------------------- 00151 //----------------------------------------------------------------------------- 00152 00153 virtual void Detach() = 0; 00154 00155 //----------------------------------------------------------------------------- 00174 //----------------------------------------------------------------------------- 00175 00176 virtual bool Enumerate(void *&jar, char *&key, void *&val) = 0; 00177 00178 //----------------------------------------------------------------------------- 00191 //----------------------------------------------------------------------------- 00192 00193 virtual bool Enumerate(void *&jar) = 0; 00194 00195 //----------------------------------------------------------------------------- 00227 //----------------------------------------------------------------------------- 00228 00229 virtual int Info(const char *vname, char *buff=0, int blen=0) = 0; 00230 00231 //----------------------------------------------------------------------------- 00244 //----------------------------------------------------------------------------- 00245 00246 virtual bool GetItem(void *data, const char *key, int hash=0) = 0; 00247 00248 //----------------------------------------------------------------------------- 00274 //----------------------------------------------------------------------------- 00275 00276 struct NewParms 00277 {const char *impl; 00278 const char *path; 00279 const char *typeID; 00280 int typeSz; 00281 int hashID; 00282 }; 00283 00284 static 00285 XrdSsiShMat *New(NewParms &parms); 00286 00287 //----------------------------------------------------------------------------- 00298 //----------------------------------------------------------------------------- 00299 00300 virtual bool Resize(CRZParms &parms) = 0; 00301 00302 //----------------------------------------------------------------------------- 00307 //----------------------------------------------------------------------------- 00308 00309 virtual bool Sync() = 0; 00310 00311 //----------------------------------------------------------------------------- 00324 //----------------------------------------------------------------------------- 00325 00326 virtual bool Sync(bool dosync, bool syncdo=false) = 0; 00327 00328 //----------------------------------------------------------------------------- 00335 //----------------------------------------------------------------------------- 00336 00337 virtual bool Sync(int synqsz) = 0; 00338 00339 //----------------------------------------------------------------------------- 00341 //----------------------------------------------------------------------------- 00342 00343 XrdSsiShMat(NewParms &parms) 00344 : shmImpl(strdup(parms.impl)), shmPath(strdup(parms.path)), 00345 shmType(strdup(parms.typeID)), shmTypeSz(parms.typeSz), 00346 shmHash(parms.hashID) 00347 {} 00348 00349 //----------------------------------------------------------------------------- 00351 //----------------------------------------------------------------------------- 00352 00353 virtual ~XrdSsiShMat() {if (shmImpl) free(shmImpl); 00354 if (shmPath) free(shmPath); 00355 if (shmType) free(shmType); 00356 } 00357 00358 protected: 00359 00360 char *shmImpl; 00361 char *shmPath; 00362 char *shmType; 00363 int shmTypeSz; 00364 int shmHash; 00365 }; 00366 #endif