EPICS Base  7.0.6.1
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
bucketLib.h
Go to the documentation of this file.
1 /*************************************************************************\
2 * Copyright (c) 2002 The University of Chicago, as Operator of Argonne
3 * National Laboratory.
4 * Copyright (c) 2002 The Regents of the University of California, as
5 * Operator of Los Alamos National Laboratory.
6 * SPDX-License-Identifier: EPICS
7 * EPICS BASE is distributed subject to a Software License Agreement found
8 * in file LICENSE that is included with this distribution.
9 \*************************************************************************/
23 #ifndef INCbucketLibh
24 #define INCbucketLibh
25 
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29 
30 #include "errMdef.h"
31 #include "epicsTypes.h"
32 #include "libComAPI.h"
33 
35 typedef unsigned BUCKETID;
36 
38 typedef enum {bidtUnsigned, bidtPointer, bidtString} buckTypeOfId;
39 
41 typedef struct item{
42  struct item *pItem;
43  const void *pId;
44  const void *pApp;
45  buckTypeOfId type;
46 }ITEM;
47 
49 typedef struct bucket{
50  ITEM **pTable;
51  void *freeListPVT;
52  unsigned hashIdMask;
53  unsigned hashIdNBits;
54  unsigned nInUse;
55 }BUCKET;
61 LIBCOM_API BUCKET * epicsStdCall bucketCreate (unsigned nHashTableEntries);
68 LIBCOM_API int epicsStdCall bucketFree (BUCKET *prb);
74 LIBCOM_API int epicsStdCall bucketShow (BUCKET *prb);
75 
83 LIBCOM_API int epicsStdCall bucketAddItemUnsignedId (BUCKET *prb,
84  const unsigned *pId, const void *pApp);
92 LIBCOM_API int epicsStdCall bucketAddItemPointerId (BUCKET *prb,
93  void * const *pId, const void *pApp);
101 LIBCOM_API int epicsStdCall bucketAddItemStringId (BUCKET *prb,
102  const char *pId, const void *pApp);
109 LIBCOM_API int epicsStdCall bucketRemoveItemUnsignedId (BUCKET *prb, const unsigned *pId);
116 LIBCOM_API int epicsStdCall bucketRemoveItemPointerId (BUCKET *prb, void * const *pId);
123 LIBCOM_API int epicsStdCall bucketRemoveItemStringId (BUCKET *prb, const char *pId);
130 LIBCOM_API void * epicsStdCall bucketLookupItemUnsignedId (BUCKET *prb, const unsigned *pId);
137 LIBCOM_API void * epicsStdCall bucketLookupItemPointerId (BUCKET *prb, void * const *pId);
144 LIBCOM_API void * epicsStdCall bucketLookupItemStringId (BUCKET *prb, const char *pId);
145 
152 LIBCOM_API void * epicsStdCall bucketLookupAndRemoveItemUnsignedId (BUCKET *prb, const unsigned *pId);
159 LIBCOM_API void * epicsStdCall bucketLookupAndRemoveItemPointerId (BUCKET *prb, void * const *pId);
166 LIBCOM_API void * epicsStdCall bucketLookupAndRemoveItemStringId (BUCKET *prb, const char *pId);
167 
168 
176 #define BUCKET_SUCCESS S_bucket_success
177 
180 #define S_bucket_success 0
181 
184 #define S_bucket_noMemory (M_bucket | 1) /*Memory allocation failed*/
185 
188 #define S_bucket_idInUse (M_bucket | 2) /*Identifier already in use*/
189 
192 #define S_bucket_uknId (M_bucket | 3) /*Unknown identifier*/
193 
195 #ifdef __cplusplus
196 }
197 #endif
198 
199 #endif /*INCbucketLibh*/
unsigned BUCKETID
Internal: bucket identifier.
Definition: bucketLib.h:35
buckTypeOfId
Internal: bucket key type.
Definition: bucketLib.h:38
LIBCOM_API BUCKET *epicsStdCall bucketCreate(unsigned nHashTableEntries)
Creates a new hash table.
LIBCOM_API int epicsStdCall bucketAddItemPointerId(BUCKET *prb, void *const *pId, const void *pApp)
Add an item identified by a pointer to the table.
LIBCOM_API int epicsStdCall bucketRemoveItemUnsignedId(BUCKET *prb, const unsigned *pId)
Remove an item identified by a string from the table.
LIBCOM_API void *epicsStdCall bucketLookupAndRemoveItemPointerId(BUCKET *prb, void *const *pId)
Find and delete an item identified by a pointer from the table.
LIBCOM_API int epicsStdCall bucketRemoveItemPointerId(BUCKET *prb, void *const *pId)
Remove an item identified by a pointer from the table.
LIBCOM_API int epicsStdCall bucketFree(BUCKET *prb)
Release memory used by a hash table.
The core data types used by epics.
LIBCOM_API int epicsStdCall bucketRemoveItemStringId(BUCKET *prb, const char *pId)
Remove an item identified by a string from the table.
Internal: bucket item structure.
Definition: bucketLib.h:41
LIBCOM_API int epicsStdCall bucketShow(BUCKET *prb)
Display information about a hash table.
LIBCOM_API void *epicsStdCall bucketLookupAndRemoveItemUnsignedId(BUCKET *prb, const unsigned *pId)
Find and delete an item identified by an unsigned int from the table.
LIBCOM_API int epicsStdCall bucketAddItemUnsignedId(BUCKET *prb, const unsigned *pId, const void *pApp)
Add an item identified by an unsigned int to the table.
LIBCOM_API void *epicsStdCall bucketLookupAndRemoveItemStringId(BUCKET *prb, const char *pId)
Find and delete an item identified by a string from the table.
Internal: Hash table structure.
Definition: bucketLib.h:49
LIBCOM_API int epicsStdCall bucketAddItemStringId(BUCKET *prb, const char *pId, const void *pApp)
Add an item identified by a string to the table.
LIBCOM_API void *epicsStdCall bucketLookupItemUnsignedId(BUCKET *prb, const unsigned *pId)
Find an item identified by an unsigned int in the table.
LIBCOM_API void *epicsStdCall bucketLookupItemStringId(BUCKET *prb, const char *pId)
Find an item identified by a string in the table.
LIBCOM_API void *epicsStdCall bucketLookupItemPointerId(BUCKET *prb, void *const *pId)
Find an item identified by a pointer in the table.