Barracuda Application Server C/C++ Reference
Native APIs, integration guides, and platform interfaces
HashTable.h
1/*
2 * ____ _________ __ _
3 * / __ \___ ____ _/ /_ __(_)___ ___ ___ / / ____ ____ _(_)____
4 * / /_/ / _ \/ __ `/ / / / / / __ `__ \/ _ \/ / / __ \/ __ `/ / ___/
5 * / _, _/ __/ /_/ / / / / / / / / / / / __/ /___/ /_/ / /_/ / / /__
6 * /_/ |_|\___/\__,_/_/ /_/ /_/_/ /_/ /_/\___/_____/\____/\__, /_/\___/
7 * /____/
8 *
9 * Barracuda Embedded Web-Server
10 *
11 ****************************************************************************
12 * HEADER
13 *
14 * $Id: HashTable.h 4915 2021-12-01 18:26:55Z wini $
15 *
16 * COPYRIGHT: Real Time Logic LLC, 2010
17 *
18 * This software is copyrighted by and is the sole property of Real
19 * Time Logic LLC. All rights, title, ownership, or other interests in
20 * the software remain the property of Real Time Logic LLC. This
21 * software may only be used in accordance with the terms and
22 * conditions stipulated in the corresponding license agreement under
23 * which the software has been supplied. Any unauthorized use,
24 * duplication, transmission, distribution, or disclosure of this
25 * software is expressly forbidden.
26 *
27 * This Copyright notice may not be removed or modified without prior
28 * written consent of Real Time Logic LLC.
29 *
30 * Real Time Logic LLC. reserves the right to modify this software
31 * without notice.
32 *
33 * http://www.realtimelogic.com
34 ****************************************************************************
35 */
36#ifndef _HashTable_h
37#define _HashTable_h
38
39#include "SingleList.h"
40#include "BaServerLib.h"
41
42struct HashTableNode;
43
44typedef void (*HashTableNode_terminate)(struct HashTableNode*, void* tmobj);
45
46typedef struct HashTableNode
47{
48#ifdef __cplusplus
49 HashTableNode(const char* name, HashTableNode_terminate terminate);
50#endif
51 SingleLink super;
52 HashTableNode_terminate destructor;
53 const char* name;
54} HashTableNode;
55
56#ifdef __cplusplus
57extern "C" {
58#endif
59BA_API void HashTableNode_constructor(HashTableNode* o,
60 const char* name,
61 HashTableNode_terminate destructor);
62#define HashTableNode_terminate(o, tmObj) (*o->destructor)(o, tmObj)
63#ifdef __cplusplus
64}
65inline HashTableNode::HashTableNode(const char* name,
66 HashTableNode_terminate destructor) {
67 HashTableNode_constructor(this,name,destructor);
68}
69#endif
70
71typedef int (*HashTable_CbFunc)(void* cbObj, struct HashTableNode*);
72
73typedef struct HashTable
74{
75#ifdef __cplusplus
76 static HashTable* create(U32 noOfHashElements,AllocatorIntf* alloctr=0);
77 ~HashTable();
78 void add(HashTableNode* node);
79 HashTableNode* lookup(const char* ident);
80 void setTmObj(void* obj);
81#endif
82 void* tmObj;
83 U32 noOfHashElements;
84 SingleList table[1]; /*SingleList contain HashTableNode(s)*/
85} HashTable;
86
87#ifdef __cplusplus
88extern "C" {
89#endif
90BA_API HashTable* HashTable_create(U32 noOfHashElements, AllocatorIntf* alloc);
91BA_API void HashTable_destructor(HashTable* o);
92BA_API void HashTable_add(HashTable* o, HashTableNode* node);
93#define HashTable_setTmObj(o, tmObjMA) (o)->tmObj=tmObjMA
94BA_API HashTableNode* HashTable_lookup(HashTable* o, const char* ident);
95BA_API int HashTable_iter(HashTable* o, void* cbObj, HashTable_CbFunc cbFunc);
96#ifdef __cplusplus
97}
98inline HashTable* HashTable::create(U32 noOfHashElements, AllocatorIntf* alloc)
99{
100 return HashTable_create(noOfHashElements, alloc);
101}
102inline HashTable::~HashTable() {
103 HashTable_destructor(this);
104}
105inline void HashTable::add(HashTableNode* node) {
106 HashTable_add(this, node);
107}
108inline HashTableNode* HashTable::lookup(const char* ident) {
109 return HashTable_lookup(this, ident);
110}
111
112inline void HashTable::setTmObj(void* obj) {
113 HashTable_setTmObj(this, obj);
114}
115
116#endif
117
118
119#endif
uint32_t U32
Unsigned 32-bit integer.
Definition: GenPrimT.h:93
Memory allocation and deallocation Interface class.
Definition: AllocatorIntf.h:98