| 1 | /* | 
|---|
| 2 | * FragmentNode.hpp | 
|---|
| 3 | * | 
|---|
| 4 | *  Created on: Sep 24, 2012 | 
|---|
| 5 | *      Author: heber | 
|---|
| 6 | */ | 
|---|
| 7 |  | 
|---|
| 8 | #ifndef FRAGMENTNODE_HPP_ | 
|---|
| 9 | #define FRAGMENTNODE_HPP_ | 
|---|
| 10 |  | 
|---|
| 11 | // include config.h | 
|---|
| 12 | #ifdef HAVE_CONFIG_H | 
|---|
| 13 | #include <config.h> | 
|---|
| 14 | #endif | 
|---|
| 15 |  | 
|---|
| 16 | #include <boost/serialization/access.hpp> | 
|---|
| 17 | #include <boost/serialization/export.hpp> | 
|---|
| 18 |  | 
|---|
| 19 | #include <iosfwd> | 
|---|
| 20 |  | 
|---|
| 21 | /** FragmentNode contains all information important to homology considerations | 
|---|
| 22 | * between fragments. | 
|---|
| 23 | * | 
|---|
| 24 | * This is important to answer whether to fragments have the same structure or | 
|---|
| 25 | * not. Basically, the node simply represents an atom but without any index to | 
|---|
| 26 | * make it indistinguishable from another atom having same number of bonds and | 
|---|
| 27 | * same atomic number. | 
|---|
| 28 | * | 
|---|
| 29 | * Namely, we need: | 
|---|
| 30 | * -# charge/atomic number of the node | 
|---|
| 31 | * -# number of edges connected to this node | 
|---|
| 32 | * | 
|---|
| 33 | * Central is have this class be sortable by having comparison operators defined. | 
|---|
| 34 | */ | 
|---|
| 35 | class FragmentNode | 
|---|
| 36 | { | 
|---|
| 37 | //!> grant output operator access to internals | 
|---|
| 38 | friend std::ostream& operator<<(std::ostream &out, const FragmentNode &node); | 
|---|
| 39 | public: | 
|---|
| 40 | /** Default constructor for class FragmentNode. | 
|---|
| 41 | * | 
|---|
| 42 | * Is required to allow placement in STL containers. | 
|---|
| 43 | */ | 
|---|
| 44 | FragmentNode() : | 
|---|
| 45 | AtomicNumber(0), | 
|---|
| 46 | ConnectedEdges(0) | 
|---|
| 47 | {} | 
|---|
| 48 |  | 
|---|
| 49 | /** Constructor for class FragmentNode. | 
|---|
| 50 | * | 
|---|
| 51 | * @param _AtomicNumber atomic number of represented atom | 
|---|
| 52 | * @param _ConnectedEdges number of "bonds" of represented atom | 
|---|
| 53 | */ | 
|---|
| 54 | FragmentNode(const size_t _AtomicNumber, const size_t _ConnectedEdges) : | 
|---|
| 55 | AtomicNumber(_AtomicNumber), | 
|---|
| 56 | ConnectedEdges(_ConnectedEdges) | 
|---|
| 57 | {} | 
|---|
| 58 | ~FragmentNode() | 
|---|
| 59 | {} | 
|---|
| 60 |  | 
|---|
| 61 | FragmentNode& operator=(const FragmentNode &node); | 
|---|
| 62 |  | 
|---|
| 63 | // comparison operators to allow for sorting | 
|---|
| 64 | bool operator<(const FragmentNode &node) const; | 
|---|
| 65 | bool operator>(const FragmentNode &node) const; | 
|---|
| 66 | bool operator==(const FragmentNode &node) const; | 
|---|
| 67 | bool operator!=(const FragmentNode &node) const { | 
|---|
| 68 | return (!(*this == node)); | 
|---|
| 69 | } | 
|---|
| 70 |  | 
|---|
| 71 | const size_t getAtomicNumber() const { | 
|---|
| 72 | return AtomicNumber; | 
|---|
| 73 | } | 
|---|
| 74 |  | 
|---|
| 75 | const size_t getConnectedEdges() const { | 
|---|
| 76 | return ConnectedEdges; | 
|---|
| 77 | } | 
|---|
| 78 |  | 
|---|
| 79 | private: | 
|---|
| 80 | //!> the atomic number | 
|---|
| 81 | const size_t AtomicNumber; | 
|---|
| 82 | //!> number of connecting edges | 
|---|
| 83 | const size_t ConnectedEdges; | 
|---|
| 84 |  | 
|---|
| 85 | private: | 
|---|
| 86 | friend class boost::serialization::access; | 
|---|
| 87 | // serialization | 
|---|
| 88 | template <typename Archive> | 
|---|
| 89 | void serialize(Archive& ar, const unsigned int version) | 
|---|
| 90 | { | 
|---|
| 91 | ar & const_cast<size_t &>(AtomicNumber); | 
|---|
| 92 | ar & const_cast<size_t &>(ConnectedEdges); | 
|---|
| 93 | } | 
|---|
| 94 | }; | 
|---|
| 95 |  | 
|---|
| 96 | // we need to give this class a unique key for serialization | 
|---|
| 97 | BOOST_CLASS_EXPORT_KEY(FragmentNode) | 
|---|
| 98 |  | 
|---|
| 99 | std::ostream& operator<<(std::ostream &out, const FragmentNode &node); | 
|---|
| 100 |  | 
|---|
| 101 | #endif /* FRAGMENTNODE_HPP_ */ | 
|---|