Loading...
Searching...
No Matches
XrdSsiShMat.hh
Go to the documentation of this file.
#ifndef __SSI_SHMAT__
#define __SSI_SHMAT__
/******************************************************************************/
/* */
/* X r d S s i S h M a t . h h */
/* */
/* (c) 2015 by the Board of Trustees of the Leland Stanford, Jr., University */
/* Produced by Andrew Hanushevsky for Stanford University under contract */
/* DE-AC02-76-SFO0515 with the Department of Energy */
/* */
/* This file is part of the XRootD software suite. */
/* */
/* XRootD is free software: you can redistribute it and/or modify it under */
/* the terms of the GNU Lesser General Public License as published by the */
/* Free Software Foundation, either version 3 of the License, or (at your */
/* option) any later version. */
/* */
/* XRootD is distributed in the hope that it will be useful, but WITHOUT */
/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */
/* License for more details. */
/* */
/* You should have received a copy of the GNU Lesser General Public License */
/* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */
/* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */
/* */
/* The copyright holder's institutional names and contributor's names may not */
/* be used to endorse or promote products derived from this software without */
/* specific prior written permission of the institution or contributor. */
/******************************************************************************/
#include <cstdlib>
#include <cstring>
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
class XrdSsiShMat
{
public:
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
virtual bool AddItem(void *newdata, void *olddata, const char *key,
int hash=0, bool replace=false) = 0;
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
virtual bool Attach(int tout, bool isrw=false) = 0;
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
struct CRZParms
{int indexSz;
int maxKeys;
int maxKLen;
int mode;
signed char multW;
signed char reUse;
char rsvd[6];
CRZParms() : indexSz(0), maxKeys(0), maxKLen(0), mode(0640),
multW(-1), reUse(-1)
{memset(rsvd, -1, sizeof(rsvd));}
~CRZParms() {}
};
virtual bool Create(CRZParms &parms) = 0;
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
virtual bool Export() = 0;
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
virtual bool DelItem(void *data, const char *key, int hash=0) = 0;
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
virtual void Detach() = 0;
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
virtual bool Enumerate(void *&jar, char *&key, void *&val) = 0;
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
virtual bool Enumerate(void *&jar) = 0;
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
virtual int Info(const char *vname, char *buff=0, int blen=0) = 0;
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
virtual bool GetItem(void *data, const char *key, int hash=0) = 0;
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
struct NewParms
{const char *impl;
const char *path;
const char *typeID;
int typeSz;
int hashID;
};
static
XrdSsiShMat *New(NewParms &parms);
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
virtual bool Resize(CRZParms &parms) = 0;
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
virtual bool Sync() = 0;
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
virtual bool Sync(bool dosync, bool syncdo=false) = 0;
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
virtual bool Sync(int synqsz) = 0;
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
XrdSsiShMat(NewParms &parms)
: shmImpl(strdup(parms.impl)), shmPath(strdup(parms.path)),
shmType(strdup(parms.typeID)), shmTypeSz(parms.typeSz),
shmHash(parms.hashID)
{}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
virtual ~XrdSsiShMat() {if (shmImpl) free(shmImpl);
if (shmPath) free(shmPath);
if (shmType) free(shmType);
}
protected:
char *shmImpl;
char *shmPath;
char *shmType;
int shmTypeSz;
int shmHash;
};
#endif
XrdSsiShMat::Sync
virtual bool Sync()=0
XrdSsiShMat::shmPath
char * shmPath
Definition XrdSsiShMat.hh:361
XrdSsiShMat::shmHash
int shmHash
Definition XrdSsiShMat.hh:364
XrdSsiShMat::NewParms::typeID
const char * typeID
The name of the type associated with the key.
Definition XrdSsiShMat.hh:279
XrdSsiShMat::NewParms::impl
const char * impl
Implementation name.
Definition XrdSsiShMat.hh:277
XrdSsiShMat::New
static XrdSsiShMat * New(NewParms &parms)
Definition XrdSsiShMat.cc:39
XrdSsiShMat::DelItem
virtual bool DelItem(void *data, const char *key, int hash=0)=0
XrdSsiShMat::Enumerate
virtual bool Enumerate(void *&jar, char *&key, void *&val)=0
XrdSsiShMat::shmTypeSz
int shmTypeSz
Definition XrdSsiShMat.hh:363
XrdSsiShMat::Resize
virtual bool Resize(CRZParms &parms)=0
XrdSsiShMat::NewParms::path
const char * path
The path to the backing file for the table.
Definition XrdSsiShMat.hh:278
XrdSsiShMat::XrdSsiShMat
XrdSsiShMat(NewParms &parms)
Constructor (arguments the same as for New()).
Definition XrdSsiShMat.hh:343
XrdSsiShMat::~XrdSsiShMat
virtual ~XrdSsiShMat()
Destructor. Warning, your destructor should call your own Detach()!
Definition XrdSsiShMat.hh:353
XrdSsiShMat::Attach
virtual bool Attach(int tout, bool isrw=false)=0
XrdSsiShMat::NewParms::hashID
int hashID
The hash being used (0 means the default).
Definition XrdSsiShMat.hh:281
XrdSsiShMat::Create
virtual bool Create(CRZParms &parms)=0
XrdSsiShMat::Info
virtual int Info(const char *vname, char *buff=0, int blen=0)=0
XrdSsiShMat::shmType
char * shmType
Definition XrdSsiShMat.hh:362
XrdSsiShMat::Export
virtual bool Export()=0
XrdSsiShMat::NewParms::typeSz
int typeSz
Size of the type in bytes.
Definition XrdSsiShMat.hh:280
XrdSsiShMat::shmImpl
char * shmImpl
Definition XrdSsiShMat.hh:360
XrdSsiShMat::Sync
virtual bool Sync(int synqsz)=0
XrdSsiShMat::Detach
virtual void Detach()=0
Detach the map from the shared memory.
XrdSsiShMat::Sync
virtual bool Sync(bool dosync, bool syncdo=false)=0
XrdSsiShMat::AddItem
virtual bool AddItem(void *newdata, void *olddata, const char *key, int hash=0, bool replace=false)=0
XrdSsiShMat::GetItem
virtual bool GetItem(void *data, const char *key, int hash=0)=0
XrdSsiShMat::Enumerate
virtual bool Enumerate(void *&jar)=0
XrdSsiShMat::NewParms
Definition XrdSsiShMat.hh:277
XrdSsiShMat::CRZParms
Definition XrdSsiShMat.hh:100
XrdSsiShMat::CRZParms::rsvd
char rsvd[6]
Reserved for future options.
Definition XrdSsiShMat.hh:112
XrdSsiShMat::CRZParms::maxKeys
int maxKeys
Maximum number of keys-value pairs expected in table.
Definition XrdSsiShMat.hh:101
XrdSsiShMat::CRZParms::reUse
signed char reUse
Definition XrdSsiShMat.hh:108
XrdSsiShMat::CRZParms::~CRZParms
~CRZParms()
Definition XrdSsiShMat.hh:117
XrdSsiShMat::CRZParms::maxKLen
int maxKLen
The maximum acceptable key length.
Definition XrdSsiShMat.hh:102
XrdSsiShMat::CRZParms::mode
int mode
Filemode for the newly created file.
Definition XrdSsiShMat.hh:103
XrdSsiShMat::CRZParms::CRZParms
CRZParms()
Definition XrdSsiShMat.hh:114
XrdSsiShMat::CRZParms::multW
signed char multW
Definition XrdSsiShMat.hh:104
XrdSsiShMat::CRZParms::indexSz
int indexSz
Number of four byte hash table entries to create.
Definition XrdSsiShMat.hh:100