Initial import of the CDE 2.1.30 sources from the Open Group.
[oweals/cde.git] / cde / programs / nsgmls / HashTableItemBase.h
1 /* $XConsortium: HashTableItemBase.h /main/1 1996/07/29 16:53:09 cde-hp $ */
2 // Copyright (c) 1994 James Clark
3 // See the file COPYING for copying permission.
4
5 #ifndef HashTableItemBase_INCLUDED
6 #define HashTableItemBase_INCLUDED 1
7
8 // All hash tables with the same type of key share object code.
9 // The cost of this is a virtual dtor in HashTableItemBase.
10
11 #ifdef SP_NAMESPACE
12 namespace SP_NAMESPACE {
13 #endif
14
15 template<class K>
16 class HashTableItemBase {
17 public:
18   HashTableItemBase(const K &k);
19   virtual ~HashTableItemBase();
20   virtual HashTableItemBase<K> *copy() const = 0;
21   K key;
22 };
23
24 template<class K>
25 struct HashTableKeyFunction {
26   static inline const K &key(const HashTableItemBase<K> &obj) {
27     return obj.key;
28   }
29 };
30
31 #ifdef SP_NAMESPACE
32 }
33 #endif
34
35 #endif /* not HashTableItemBase_INCLUDED */
36
37 #ifdef SP_DEFINE_TEMPLATES
38 #include "HashTableItemBase.C"
39 #endif