| 1 | #ifndef PERIODENTAFEL_HPP_ | 
|---|
| 2 | #define PERIODENTAFEL_HPP_ | 
|---|
| 3 |  | 
|---|
| 4 | /*********************************************** includes ***********************************/ | 
|---|
| 5 |  | 
|---|
| 6 | // include config.h | 
|---|
| 7 | #ifdef HAVE_CONFIG_H | 
|---|
| 8 | #include <config.h> | 
|---|
| 9 | #endif | 
|---|
| 10 |  | 
|---|
| 11 | #include <iosfwd> | 
|---|
| 12 | #include <map> | 
|---|
| 13 | #include <string> | 
|---|
| 14 |  | 
|---|
| 15 | #include "Helpers/defs.hpp" | 
|---|
| 16 | #include "types.hpp" | 
|---|
| 17 |  | 
|---|
| 18 | #include <boost/version.hpp> | 
|---|
| 19 | #if BOOST_VERSION > 106300 | 
|---|
| 20 | #include <boost/serialization/array_wrapper.hpp> | 
|---|
| 21 | #endif | 
|---|
| 22 | #include "boost/serialization/array.hpp" | 
|---|
| 23 | #include "boost/serialization/map.hpp" | 
|---|
| 24 |  | 
|---|
| 25 | /****************************************** forward declarations *****************************/ | 
|---|
| 26 |  | 
|---|
| 27 | class element; | 
|---|
| 28 | class ion; | 
|---|
| 29 |  | 
|---|
| 30 | /********************************************** declarations *******************************/ | 
|---|
| 31 |  | 
|---|
| 32 |  | 
|---|
| 33 | /** Periodentafel is a list of all elements sorted by their atomic number. | 
|---|
| 34 | */ | 
|---|
| 35 | class periodentafel { | 
|---|
| 36 | /******* Types *********/ | 
|---|
| 37 | friend class periodentafelTest; | 
|---|
| 38 | private: | 
|---|
| 39 | typedef std::map<atomicNumber_t,element*> elementSet; | 
|---|
| 40 | typedef std::map<int,ion*> ionSet; | 
|---|
| 41 | typedef std::map<atomicNumber_t,ionSet> IonsPerElement; | 
|---|
| 42 | public: | 
|---|
| 43 | typedef elementSet::iterator iterator; | 
|---|
| 44 | typedef elementSet::const_iterator const_iterator; | 
|---|
| 45 | typedef std::reverse_iterator<const_iterator> reverse_iterator; | 
|---|
| 46 |  | 
|---|
| 47 | /******* Functions *********/ | 
|---|
| 48 | public: | 
|---|
| 49 | periodentafel(const bool DoLoad = false); | 
|---|
| 50 | ~periodentafel(); | 
|---|
| 51 |  | 
|---|
| 52 | iterator AddElement(element * pointer); | 
|---|
| 53 | size_t RemoveElement(const element * pointer); | 
|---|
| 54 | size_t RemoveElement(atomicNumber_t); | 
|---|
| 55 | void CleanupPeriodtable(); | 
|---|
| 56 | const element * FindElement(atomicNumber_t) const; | 
|---|
| 57 | const element * FindElement(atomicNumber_t, const int); | 
|---|
| 58 | const element * FindElement(const std::string &shorthand) const; | 
|---|
| 59 | const element * AskElement() const; | 
|---|
| 60 | const element * EnterElement(); | 
|---|
| 61 |  | 
|---|
| 62 | const_iterator begin() const; | 
|---|
| 63 | const_iterator end() const; | 
|---|
| 64 | reverse_iterator rbegin() const; | 
|---|
| 65 | reverse_iterator rend() const; | 
|---|
| 66 | bool Output(std::ostream * const output) const; | 
|---|
| 67 | void OutputElement(std::ostream * const output, const element *elem) const; | 
|---|
| 68 | bool LoadPeriodentafel(const char * const path); | 
|---|
| 69 | bool StorePeriodentafel(const char * const path) const; | 
|---|
| 70 |  | 
|---|
| 71 | bool operator==(const periodentafel &other) const; | 
|---|
| 72 |  | 
|---|
| 73 | bool operator!=(const periodentafel &other) const { | 
|---|
| 74 | return !(*this == other); | 
|---|
| 75 | } | 
|---|
| 76 |  | 
|---|
| 77 | private: | 
|---|
| 78 | friend class boost::serialization::access; | 
|---|
| 79 | // serialization | 
|---|
| 80 | template<class Archive> | 
|---|
| 81 | void serialize(Archive & ar, const unsigned int version) | 
|---|
| 82 | { | 
|---|
| 83 | ar & boost::serialization::make_array<char>(header1, MAXSTRINGSIZE); | 
|---|
| 84 | ar & boost::serialization::make_array<char>(header2, MAXSTRINGSIZE); | 
|---|
| 85 | ar & elements; | 
|---|
| 86 | ar & ions; | 
|---|
| 87 | } | 
|---|
| 88 |  | 
|---|
| 89 | void ScanPeriodentafel(); | 
|---|
| 90 | bool LoadColorDatabase(std::istream &input); | 
|---|
| 91 | bool LoadElementsDatabase(std::istream &input); | 
|---|
| 92 | bool LoadElectronegativityDatabase(std::istream &input); | 
|---|
| 93 | bool LoadValenceDatabase(std::istream &input); | 
|---|
| 94 | bool LoadOrbitalsDatabase(std::istream &input); | 
|---|
| 95 | bool LoadHBondAngleDatabase(std::istream &input); | 
|---|
| 96 | bool LoadHBondLengthsDatabase(std::istream &input); | 
|---|
| 97 |  | 
|---|
| 98 | /******* Variables *********/ | 
|---|
| 99 | private: | 
|---|
| 100 | char header1[MAXSTRINGSIZE]; //!< store first header line | 
|---|
| 101 | char header2[MAXSTRINGSIZE]; //!< store second header line | 
|---|
| 102 |  | 
|---|
| 103 | elementSet elements; | 
|---|
| 104 | IonsPerElement ions; | 
|---|
| 105 | }; | 
|---|
| 106 |  | 
|---|
| 107 | #endif /*PERIODENTAFEL_HPP_*/ | 
|---|