home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 1997 November
/
PCWorld_1997-11_cd.bin
/
software
/
programy
/
komix
/
DATA.Z
/
NmFuncMap.hxx
< prev
next >
Wrap
Text File
|
1996-05-31
|
1KB
|
56 lines
/*---------------------------------------------------------------------------
*
* (c) Westmount Technology 1993
*
* File: @(#)NmFuncMap.hxx 1.1
* Author: frmo, peku
* Description: A mapping from a name to a pointer to function
* uses RogueWave RWCString and RWTValHashDictionary
*---------------------------------------------------------------------------
SccsId = @(#)NmFuncMap.hxx 1.1 21 Feb 1994 Copyright 1994 Westmount Technology */
#ifndef NMFUNCMAP_HXX
#define NMFUNCMAP_HXX
#ifndef __RWCSTRING_H__
#include "rw/cstring.h"
#endif
#ifndef __RWTVHDICT_H__
#include "rw/tvhdict.h"
#endif
typedef void* voidptr;
unsigned WmtRWTHashRWCString(const RWCString& s);
template<class T>
class NmFuncMap : private RWTValHashDictionary<RWCString, voidptr> {
public:
NmFuncMap() :
RWTValHashDictionary<RWCString, voidptr>(WmtRWTHashRWCString)
{
}
void set(const RWCString &key, T func)
{
RWTValHashDictionary<RWCString, voidptr>::
insertKeyAndValue(*new RWCString(key), func);
}
T get(const RWCString &key) const
{
voidptr val;
RWTValHashDictionary<RWCString, voidptr>::findValue(key, val);
return (T) val;
}
void remove(const RWCString &key)
{
RWTValHashDictionary<RWCString, voidptr>::remove(key);
}
int isPresent(const RWCString &key) const
{
return RWTValHashDictionary<RWCString, voidptr>::contains(key);
}
};
#endif /* NMFUNCMAP_HXX */