#ifndef Chimera_NameMap_h # define Chimera_NameMap_h # if defined(_MSC_VER) && (_MSC_VER >= 1020) # pragma once # endif # ifndef WrapPy # include # include # include # include "Symbol.h" # include "_chimera_config.h" # ifdef CHIMERA_STD_HASH # include # else # include # endif #ifdef CHIMERA_STD_HASH namespace std { template struct hash { size_t operator()(klass* k) const { #ifdef CHIMERA_64BITPTR std::hash h; return h(reinterpret_cast(k)); #else std::hash h; return h(reinterpret_cast(k)); #endif } }; } // namespace std #endif namespace chimera { template class CHIMERA_IMEX Name { public: # ifdef CHIMERA_STD_HASH typedef std::hash_map*> NameMap; # else typedef std::map*> NameMap; # endif typedef std::pair NameMapRange; static klass* lookup(Symbol name); static void remove(Symbol name) throw (); static NameMapRange list() throw (); Name() {} virtual ~Name(); Symbol name() const throw (); // Use save and remove instead of a setName() api so Python can // transfer ownership to C++ on a save and get it back on a remove. void save(Symbol name) throw (std::logic_error); void remove() throw (); protected: # ifdef CHIMERA_STD_HASH typedef std::hash_map*, Symbol> BackMap; # else typedef std::map*, Symbol> BackMap; # endif static NameMap all; static BackMap back; }; } // namespace chimera # endif /* WrapPy */ #endif