2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these libraries and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
23 /* $XConsortium: NamedTable.h /main/2 1996/08/13 10:09:04 mgreess $ */
24 // Copyright (c) 1994 James Clark
25 // See the file COPYING for copying permission.
27 #ifndef NamedTable_INCLUDED
28 #define NamedTable_INCLUDED 1
33 #include "OwnerTable.h"
36 namespace SP_NAMESPACE {
39 class NamedTableKeyFunction {
41 static inline const StringC &key(const Named &obj) { return obj.name(); }
44 template<class T> class NamedTableIter;
45 template<class T> class ConstNamedTableIter;
51 T *insert(T *p) { return (T *)table_.insert(p); }
52 T *lookup(const StringC &str) const { return (T *)table_.lookup(str); }
53 T *remove(const StringC &str) { return (T *)table_.remove(str); }
54 size_t count() const { return table_.count(); }
55 void clear() { table_.clear(); }
56 void swap(NamedTable<T> &to) { table_.swap(to.table_); }
58 NamedTable(const NamedTable<T> &) {}
59 void operator=(const NamedTable<T> &) {}
60 OwnerTable<Named, StringC, Hash, NamedTableKeyFunction>
62 friend class NamedTableIter<T>;
63 friend class ConstNamedTableIter<T>;
67 class NamedTableIter {
69 NamedTableIter(const NamedTable<T> &table) : iter_(table.table_) { }
70 T *next() { return (T *)iter_.next(); }
72 OwnerTableIter<Named, StringC, Hash, NamedTableKeyFunction> iter_;
76 class ConstNamedTableIter {
78 ConstNamedTableIter(const NamedTable<T> &table) : iter_(table.table_) { }
79 const T *next() { return (T *)iter_.next(); }
81 OwnerTableIter<Named, StringC, Hash, NamedTableKeyFunction> iter_;
88 #endif /* not NamedTable_INCLUDED */