// ============================================================= // ANSR.h �1999-2002, J.T. Frey // ============================================================= // Written: J.T. Frey, 23.FEB.2002 // Purpose: Atomic Number/Symbol Resolution class. // // Last Mod: 05.Feb.2003: Removed all ostream::form calls and moved to purely // C++ stream operators. #ifndef __ANSRDB__ #define __ANSRDB__ #include #ifndef SGI #include #else #include #endif using namespace std; // ///////////////////////////////////////////////////////// // TElementSymbol - four-character entity, masquerading // as a simple 32-bit integer! For any symbol/number // that we can't resolve, there's a constant, too: // typedef uint32_t TElementSymbol; #define kANSRInvalidSymbol (TElementSymbol)-1 // ///////////////////////////////////////////////////////// // TElementInfo - data structure which contains an // element's information. // typedef struct TElementInfo { unsigned atomicNumber; TElementSymbol chemSymbol; double weight; } TElementInfo; // ///////////////////////////////////////////////////////// // ANSRDB - Atomic Number/Symbol Resolution Data Base // class ANSRDB { public: ANSRDB(); ANSRDB(const char* filepath); ~ANSRDB(); static ANSRDB* DefaultANSRDB(); static TElementSymbol MakeSymbolFromString(const char* string); TElementSymbol LookupSymbolForNumber(unsigned number); unsigned LookupNumberForSymbol(TElementSymbol symbol); TElementInfo* LookupElementInfoForNumber(unsigned number); TElementInfo* LookupElementInfoForSymbol(TElementSymbol symbol); void print(ostream& os); protected: unsigned elementsInTable; TElementInfo* elements; unsigned* lookupTable; private: int DidInitializeTables(); int DidReadTableFromFile(const char* filepath); }; #endif