home *** CD-ROM | disk | FTP | other *** search
- /*---------------------------------------------------------------------------
- *
- * (c) Westmount Technology 1993
- *
- * File: @(#)NmFuncMap.hxx 1.3
- * Author: Fred Mol
- * Description: A mapping from a name to a pointer to function
- *---------------------------------------------------------------------------
- SccsId = @(#)NmFuncMap.hxx 1.3 11 Nov 1993 Copyright 1993 Westmount Technology */
-
- #ifndef NMFUNCMAP_HXX
- #define NMFUNCMAP_HXX
-
- #ifndef TEMPLCONF_HXX
- #include "TemplConf.hxx"
- #endif
-
- #ifndef STRINGHASH_HXX
- #include "StringHash.hxx"
- #endif
-
- #ifndef PTRDICT_HXX
- #include "PtrDict.hxx"
- #endif
-
- #if HAS_TEMPLATES
-
- template<class T>
- class NmFuncMap : private GenPtrDict {
- public:
- void set(const StringHash &key, T func)
- { GenPtrDict::set(new StringHash(key), func); }
- T get(const StringHash &key)
- { return (T) GenPtrDict::get(key); }
- void remove(const StringHash &key)
- { GenPtrDict::remove(key); }
- int isPresent(const StringHash &key)
- { return GenPtrDict::isPresent(key); }
-
- const StringHash *firstKey()
- { return (StringHash *) GenPtrDict::firstKey(); }
- const StringHash *nextKey()
- { return (StringHash *) GenPtrDict::nextKey(); }
-
- T firstValue()
- { return (T) GenPtrDict::firstValue(); }
- T nextValue()
- { return (T) GenPtrDict::nextValue(); }
- };
-
- #else
-
- #define NmFuncMap_(func) name2(func,_NmFuncMap)
-
- #define NmFuncMapdeclare(Func) \
- class NmFuncMap_(Func) : private GenPtrDict { \
- public: \
- void set(const StringHash &key, Func func) \
- { GenPtrDict::set(new StringHash(key), func); } \
- Func get(const StringHash &key) \
- { return (Func) GenPtrDict::get(key); } \
- void remove(const StringHash &key) \
- { GenPtrDict::remove(key); } \
- int isPresent(const StringHash &key) \
- { return GenPtrDict::isPresent(key); } \
- \
- const StringHash *firstKey() \
- { return (StringHash *) GenPtrDict::firstKey(); } \
- const StringHash *nextKey() \
- { return (StringHash *) GenPtrDict::nextKey(); } \
- \
- Func firstValue() \
- { return (Func) GenPtrDict::firstValue(); } \
- Func nextValue() \
- { return (Func) GenPtrDict::nextValue(); } \
- }
-
- #endif /* HAS_TEMPLATES */
-
- #endif /* NMFUNCMAP_HXX */
-