XRootD
Loading...
Searching...
No Matches
XrdSsiShMat.hh
Go to the documentation of this file.
1#ifndef __SSI_SHMAT__
2#define __SSI_SHMAT__
3/******************************************************************************/
4/* */
5/* X r d S s i S h M a t . h h */
6/* */
7/* (c) 2015 by the Board of Trustees of the Leland Stanford, Jr., University */
8/* Produced by Andrew Hanushevsky for Stanford University under contract */
9/* DE-AC02-76-SFO0515 with the Department of Energy */
10/* */
11/* This file is part of the XRootD software suite. */
12/* */
13/* XRootD is free software: you can redistribute it and/or modify it under */
14/* the terms of the GNU Lesser General Public License as published by the */
15/* Free Software Foundation, either version 3 of the License, or (at your */
16/* option) any later version. */
17/* */
18/* XRootD is distributed in the hope that it will be useful, but WITHOUT */
19/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
20/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */
21/* License for more details. */
22/* */
23/* You should have received a copy of the GNU Lesser General Public License */
24/* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */
25/* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */
26/* */
27/* The copyright holder's institutional names and contributor's names may not */
28/* be used to endorse or promote products derived from this software without */
29/* specific prior written permission of the institution or contributor. */
30/******************************************************************************/
31
32#include <cstdlib>
33#include <cstring>
34
35//-----------------------------------------------------------------------------
39//-----------------------------------------------------------------------------
40
42{
43public:
44
45//-----------------------------------------------------------------------------
61//-----------------------------------------------------------------------------
62
63virtual bool AddItem(void *newdata, void *olddata, const char *key,
64 int hash=0, bool replace=false) = 0;
65
66//-----------------------------------------------------------------------------
82//-----------------------------------------------------------------------------
83
84virtual bool Attach(int tout, bool isrw=false) = 0;
85
86//-----------------------------------------------------------------------------
97//-----------------------------------------------------------------------------
98
100 {int indexSz;
103 int mode;
104 signed char multW;
108 signed char reUse;
112 char rsvd[6];
113
114 CRZParms() : indexSz(0), maxKeys(0), maxKLen(0), mode(0640),
115 multW(-1), reUse(-1)
116 {memset(rsvd, -1, sizeof(rsvd));}
118 };
119
120virtual bool Create(CRZParms &parms) = 0;
121
122//-----------------------------------------------------------------------------
127//-----------------------------------------------------------------------------
128
129virtual bool Export() = 0;
130
131//-----------------------------------------------------------------------------
145//-----------------------------------------------------------------------------
146
147virtual bool DelItem(void *data, const char *key, int hash=0) = 0;
148
149//-----------------------------------------------------------------------------
151//-----------------------------------------------------------------------------
152
153virtual void Detach() = 0;
154
155//-----------------------------------------------------------------------------
174//-----------------------------------------------------------------------------
175
176virtual bool Enumerate(void *&jar, char *&key, void *&val) = 0;
177
178//-----------------------------------------------------------------------------
191//-----------------------------------------------------------------------------
192
193virtual bool Enumerate(void *&jar) = 0;
194
195//-----------------------------------------------------------------------------
227//-----------------------------------------------------------------------------
228
229virtual int Info(const char *vname, char *buff=0, int blen=0) = 0;
230
231//-----------------------------------------------------------------------------
244//-----------------------------------------------------------------------------
245
246virtual bool GetItem(void *data, const char *key, int hash=0) = 0;
247
248//-----------------------------------------------------------------------------
274//-----------------------------------------------------------------------------
275
277 {const char *impl;
278 const char *path;
279 const char *typeID;
280 int typeSz;
281 int hashID;
282 };
283
284static
285XrdSsiShMat *New(NewParms &parms);
286
287//-----------------------------------------------------------------------------
298//-----------------------------------------------------------------------------
299
300virtual bool Resize(CRZParms &parms) = 0;
301
302//-----------------------------------------------------------------------------
307//-----------------------------------------------------------------------------
308
309virtual bool Sync() = 0;
310
311//-----------------------------------------------------------------------------
324//-----------------------------------------------------------------------------
325
326virtual bool Sync(bool dosync, bool syncdo=false) = 0;
327
328//-----------------------------------------------------------------------------
335//-----------------------------------------------------------------------------
336
337virtual bool Sync(int synqsz) = 0;
338
339//-----------------------------------------------------------------------------
341//-----------------------------------------------------------------------------
342
344 : shmImpl(strdup(parms.impl)), shmPath(strdup(parms.path)),
345 shmType(strdup(parms.typeID)), shmTypeSz(parms.typeSz),
346 shmHash(parms.hashID)
347 {}
348
349//-----------------------------------------------------------------------------
351//-----------------------------------------------------------------------------
352
353virtual ~XrdSsiShMat() {if (shmImpl) free(shmImpl);
354 if (shmPath) free(shmPath);
355 if (shmType) free(shmType);
356 }
357
358protected:
359
365};
366#endif
virtual bool Sync()=0
const char * typeID
The name of the type associated with the key.
const char * impl
Implementation name.
static XrdSsiShMat * New(NewParms &parms)
virtual bool DelItem(void *data, const char *key, int hash=0)=0
virtual bool Enumerate(void *&jar, char *&key, void *&val)=0
virtual bool Resize(CRZParms &parms)=0
const char * path
The path to the backing file for the table.
XrdSsiShMat(NewParms &parms)
Constructor (arguments the same as for New())
virtual ~XrdSsiShMat()
Destructor. Warning, your destructor should call your own Detach()!
virtual bool Attach(int tout, bool isrw=false)=0
int hashID
The hash being used (0 means the default)
virtual bool Create(CRZParms &parms)=0
virtual int Info(const char *vname, char *buff=0, int blen=0)=0
virtual bool Export()=0
int typeSz
Size of the type in bytes.
virtual bool Sync(int synqsz)=0
virtual void Detach()=0
Detach the map from the shared memory.
virtual bool Sync(bool dosync, bool syncdo=false)=0
virtual bool AddItem(void *newdata, void *olddata, const char *key, int hash=0, bool replace=false)=0
virtual bool GetItem(void *data, const char *key, int hash=0)=0
virtual bool Enumerate(void *&jar)=0
char rsvd[6]
Reserved for future options.
int maxKeys
Maximum number of keys-value pairs expected in table.
int maxKLen
The maximum acceptable key length.
int mode
Filemode for the newly created file.
int indexSz
Number of four byte hash table entries to create.