1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
/* Copyright (C) 2003 MySQL AB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */
#ifndef KEY_TABLE2_REF_HPP
#define KEY_TABLE2_REF_HPP
#include "KeyTable2.hpp"
/**
* KeyTable2 is DLHashTable2 with hardcoded Uint32 key named "key".
*/
template <class T, class U, class V>
class KeyTable2Ref
{
KeyTable2<U, V>& m_ref;
public:
KeyTable2Ref(KeyTable2<U, V>& ref) :m_ref(ref) {}
bool find(Ptr<T>& ptr, Uint32 key) const {
U rec;
rec.key = key;
Ptr<U> tmp;
bool ret = m_ref.find(tmp, rec);
ptr.i = tmp.i;
ptr.p = static_cast<T*>(tmp.p);
return ret;
}
bool seize(Ptr<T> & ptr) {
Ptr<U> tmp;
bool ret = m_ref.seize(tmp);
ptr.i = tmp.i;
ptr.p = static_cast<T*>(tmp.p);
return ret;
}
void add(Ptr<T> & ptr) {
Ptr<U> tmp;
tmp.i = ptr.i;
tmp.p = static_cast<U*>(ptr.p);
m_ref.add(tmp);
}
void release(Ptr<T> & ptr) {
Ptr<U> tmp;
tmp.i = ptr.i;
tmp.p = static_cast<U*>(ptr.p);
m_ref.release(tmp);
}
};
#endif
|