/* Copyright (c) 2003, 2005, 2006 MySQL AB Use is subject to license terms 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-1335 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 KeyTable2Ref { KeyTable2& m_ref; public: KeyTable2Ref(KeyTable2& ref) :m_ref(ref) {} bool find(Ptr& ptr, Uint32 key) const { U rec; rec.key = key; Ptr tmp; bool ret = m_ref.find(tmp, rec); ptr.i = tmp.i; ptr.p = static_cast(tmp.p); return ret; } bool seize(Ptr & ptr) { Ptr tmp; bool ret = m_ref.seize(tmp); ptr.i = tmp.i; ptr.p = static_cast(tmp.p); return ret; } void add(Ptr & ptr) { Ptr tmp; tmp.i = ptr.i; tmp.p = static_cast(ptr.p); m_ref.add(tmp); } void release(Ptr & ptr) { Ptr tmp; tmp.i = ptr.i; tmp.p = static_cast(ptr.p); m_ref.release(tmp); } }; #endif