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
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
Definition XrdSsiShMat.hh:42
virtual bool Sync()=0
char * shmPath
Definition XrdSsiShMat.hh:361
int shmHash
Definition XrdSsiShMat.hh:364
virtual bool DelItem(void *data, const char *key, int hash=0)=0
virtual bool Enumerate(void *&jar, char *&key, void *&val)=0
int shmTypeSz
Definition XrdSsiShMat.hh:363
virtual bool Resize(CRZParms &parms)=0
XrdSsiShMat(NewParms &parms)
Constructor (arguments the same as for New())
Definition XrdSsiShMat.hh:343
virtual ~XrdSsiShMat()
Destructor. Warning, your destructor should call your own Detach()!
Definition XrdSsiShMat.hh:353
virtual bool Attach(int tout, bool isrw=false)=0
virtual bool Create(CRZParms &parms)=0
virtual int Info(const char *vname, char *buff=0, int blen=0)=0
char * shmType
Definition XrdSsiShMat.hh:362
virtual bool Export()=0
static XrdSsiShMat * New(NewParms &parms)
char * shmImpl
Definition XrdSsiShMat.hh:360
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
Definition XrdSsiShMat.hh:100
char rsvd[6]
Reserved for future options.
Definition XrdSsiShMat.hh:112
int maxKeys
Maximum number of keys-value pairs expected in table.
Definition XrdSsiShMat.hh:101
signed char reUse
Definition XrdSsiShMat.hh:108
~CRZParms()
Definition XrdSsiShMat.hh:117
int maxKLen
The maximum acceptable key length.
Definition XrdSsiShMat.hh:102
int mode
Filemode for the newly created file.
Definition XrdSsiShMat.hh:103
CRZParms()
Definition XrdSsiShMat.hh:114
signed char multW
Definition XrdSsiShMat.hh:104
int indexSz
Number of four byte hash table entries to create.
Definition XrdSsiShMat.hh:100
Definition XrdSsiShMat.hh:277
const char * typeID
The name of the type associated with the key.
Definition XrdSsiShMat.hh:279
const char * impl
Implementation name.
Definition XrdSsiShMat.hh:277
const char * path
The path to the backing file for the table.
Definition XrdSsiShMat.hh:278
int hashID
The hash being used (0 means the default)
Definition XrdSsiShMat.hh:281
int typeSz
Size of the type in bytes.
Definition XrdSsiShMat.hh:280