[a3427f] | 1 | /*
|
---|
| 2 | * FragmentationResultContainer.hpp
|
---|
| 3 | *
|
---|
| 4 | * Created on: Mar 8, 2013
|
---|
| 5 | * Author: heber
|
---|
| 6 | */
|
---|
| 7 |
|
---|
| 8 | #ifndef FRAGMENTATIONRESULTCONTAINER_HPP_
|
---|
| 9 | #define FRAGMENTATIONRESULTCONTAINER_HPP_
|
---|
| 10 |
|
---|
| 11 | // include config.h
|
---|
| 12 | #ifdef HAVE_CONFIG_H
|
---|
| 13 | #include <config.h>
|
---|
| 14 | #endif
|
---|
| 15 |
|
---|
[55e1bc] | 16 | #include <boost/serialization/access.hpp>
|
---|
[a3427f] | 17 | #include "CodePatterns/Singleton.hpp"
|
---|
| 18 |
|
---|
[55e1bc] | 19 | #include <boost/filesystem/path.hpp>
|
---|
[a3427f] | 20 | #include <map>
|
---|
| 21 |
|
---|
[d20ded] | 22 | #include "CodePatterns/Observer/Observable.hpp"
|
---|
| 23 |
|
---|
[a3427f] | 24 | #ifdef HAVE_JOBMARKET
|
---|
| 25 | #include "JobMarket/types.hpp"
|
---|
| 26 | #else
|
---|
| 27 | typedef size_t JobId_t;
|
---|
| 28 | #endif
|
---|
| 29 |
|
---|
| 30 | #include "Fragmentation/KeySetsContainer.hpp"
|
---|
[c8d13f5] | 31 | #include "Fragmentation/Summation/IndexSet.hpp"
|
---|
| 32 | #include "Fragmentation/Summation/Containers/FragmentationShortRangeResults.hpp"
|
---|
[a3427f] | 33 | #include "Fragmentation/Summation/Containers/MPQCData.hpp"
|
---|
[c8d13f5] | 34 | #include "Fragmentation/Summation/Containers/MPQCDataMap.hpp"
|
---|
[a3427f] | 35 | #ifdef HAVE_VMG
|
---|
| 36 | #include "Fragmentation/Summation/Containers/VMGData.hpp"
|
---|
| 37 | #endif
|
---|
| 38 |
|
---|
| 39 | /** This class stores results from lengthy fragmentation calculations, e.g.
|
---|
| 40 | * coming out of FragmentationAutomationAction.
|
---|
| 41 | *
|
---|
| 42 | * The idea is that we can play around with results without having to recalculate
|
---|
[55e1bc] | 43 | * results in between. Hence, we place results into this container which we may
|
---|
| 44 | * full serialize.
|
---|
[a3427f] | 45 | */
|
---|
[d20ded] | 46 | class FragmentationResultContainer :
|
---|
| 47 | public Singleton<FragmentationResultContainer>,
|
---|
| 48 | public Observable
|
---|
[a3427f] | 49 | {
|
---|
| 50 | //!> Singleton patterns needs access to private cstor/dtor.
|
---|
| 51 | friend class Singleton<FragmentationResultContainer>;
|
---|
| 52 | private:
|
---|
| 53 | FragmentationResultContainer() :
|
---|
[d20ded] | 54 | Observable("FragmentationResultContainer"),
|
---|
[a3427f] | 55 | ResultsType(BothRanges)
|
---|
| 56 | {}
|
---|
| 57 | ~FragmentationResultContainer() {}
|
---|
| 58 |
|
---|
| 59 | public:
|
---|
| 60 | //!> typedef for short range data container
|
---|
| 61 | typedef std::map<JobId_t, MPQCData> shortrangedata_t;
|
---|
| 62 | #ifdef HAVE_VMG
|
---|
| 63 | //!> typedef for long range data container
|
---|
| 64 | typedef std::map<JobId_t, VMGData> longrangedata_t;
|
---|
| 65 | #endif
|
---|
| 66 |
|
---|
| 67 | #ifdef HAVE_VMG
|
---|
| 68 | /** Adds a a set of both short and long range results.
|
---|
| 69 | *
|
---|
| 70 | * Adds all the containers to the ones present in this instance.
|
---|
| 71 | *
|
---|
| 72 | * \param _keysets
|
---|
[adb51ab] | 73 | * \param _forcekeysetskeysets
|
---|
[a3427f] | 74 | * \param _shortrangedata
|
---|
| 75 | * \param _longrangedata
|
---|
| 76 | */
|
---|
| 77 | void addFullResults(
|
---|
| 78 | const KeySetsContainer &_keysets,
|
---|
| 79 | const KeySetsContainer &_forcekeysets,
|
---|
| 80 | const shortrangedata_t &_shortrangedata,
|
---|
| 81 | const longrangedata_t &_longrangedata
|
---|
| 82 | );
|
---|
| 83 | #endif
|
---|
| 84 |
|
---|
| 85 | /** Adds a a set of short range results only.
|
---|
| 86 | *
|
---|
| 87 | * Adds all the containers to the ones present in this instance.
|
---|
| 88 | *
|
---|
| 89 | * \param _keysets
|
---|
| 90 | * \param _forcekeysets
|
---|
| 91 | * \param _shortrangedata
|
---|
| 92 | */
|
---|
| 93 | void addShortRangeResults(
|
---|
| 94 | const KeySetsContainer &_keysets,
|
---|
| 95 | const KeySetsContainer &_forcekeysets,
|
---|
| 96 | const shortrangedata_t &_shortrangedata
|
---|
| 97 | );
|
---|
| 98 |
|
---|
[c8d13f5] | 99 | /** Adds a a set of summed short range results.
|
---|
| 100 | *
|
---|
| 101 | * Adds all the containers to the ones present in this instance.
|
---|
| 102 | *
|
---|
| 103 | * \param _summedshortrange energy results per index set
|
---|
| 104 | */
|
---|
| 105 | void addShortRangeSummedResults(
|
---|
| 106 | const FragmentationShortRangeResults::summedshortrange_t &_summedshortrange
|
---|
| 107 | );
|
---|
| 108 |
|
---|
[adb51ab] | 109 | /** Adds given cycles to internal keyset list.
|
---|
| 110 | *
|
---|
| 111 | * \param _cycles keysets of cycles to add
|
---|
| 112 | */
|
---|
| 113 | void addCycles(const KeySetsContainer &_cycles)
|
---|
| 114 | { cycles.insert(_cycles); }
|
---|
| 115 |
|
---|
[a3427f] | 116 | /** Clears all internal containers.
|
---|
| 117 | *
|
---|
| 118 | * \note Also resets ResultsType.
|
---|
| 119 | */
|
---|
| 120 | void clear()
|
---|
| 121 | {
|
---|
[d20ded] | 122 | OBSERVE;
|
---|
[a3427f] | 123 | keysets.clear();
|
---|
| 124 | forcekeysets.clear();
|
---|
| 125 | shortrangedata.clear();
|
---|
[c8d13f5] | 126 | summedshortrange.clear();
|
---|
[a3427f] | 127 | #ifdef HAVE_VMG
|
---|
| 128 | longrangedata.clear();
|
---|
| 129 | #endif
|
---|
| 130 | ResultsType = BothRanges;
|
---|
| 131 | }
|
---|
| 132 |
|
---|
| 133 | const KeySetsContainer &getKeySets() const { return keysets; }
|
---|
[adb51ab] | 134 | const KeySetsContainer &getCycles() const { return cycles; }
|
---|
[a3427f] | 135 | const KeySetsContainer &getForceKeySets() const { return forcekeysets; }
|
---|
| 136 | const shortrangedata_t& getShortRangeResults() const { return shortrangedata; }
|
---|
[c8d13f5] | 137 | const FragmentationShortRangeResults::summedshortrange_t& getShortRangeSummedResults() const { return summedshortrange; }
|
---|
[a3427f] | 138 | #ifdef HAVE_VMG
|
---|
| 139 | const longrangedata_t& getLongRangeResults() const;
|
---|
| 140 | #endif
|
---|
| 141 | bool areFullRangeResultsPresent() const { return (ResultsType == BothRanges); }
|
---|
| 142 |
|
---|
| 143 | private:
|
---|
| 144 | //!> indicates whether we contain short range only or both results
|
---|
| 145 | enum ResultsType_t {
|
---|
| 146 | ShortRangeOnly,
|
---|
| 147 | BothRanges,
|
---|
| 148 | } ResultsType;
|
---|
| 149 |
|
---|
| 150 | //!> container for all KeySet's without hydrogens to the jobs
|
---|
| 151 | KeySetsContainer keysets;
|
---|
| 152 | //!> container for all KeySet's with all except saturation hydrogen to the jobs
|
---|
| 153 | KeySetsContainer forcekeysets;
|
---|
| 154 | //!> container for all short-range results
|
---|
| 155 | std::map<JobId_t, MPQCData> shortrangedata;
|
---|
[adb51ab] | 156 | //! container of all cycle keysets
|
---|
| 157 | KeySetsContainer cycles;
|
---|
[c8d13f5] | 158 | //!> container for summed up results per index set
|
---|
| 159 | FragmentationShortRangeResults::summedshortrange_t summedshortrange;
|
---|
[a3427f] | 160 |
|
---|
| 161 | #ifdef HAVE_VMG
|
---|
| 162 | //!> container for all long-range results
|
---|
| 163 | std::map<JobId_t, VMGData> longrangedata;
|
---|
| 164 | #endif
|
---|
[55e1bc] | 165 |
|
---|
| 166 | friend class boost::serialization::access;
|
---|
| 167 | // serialization
|
---|
| 168 | template <typename Archive>
|
---|
| 169 | void serialize(Archive& ar, const unsigned int version)
|
---|
| 170 | {
|
---|
| 171 | ar & ResultsType;
|
---|
| 172 | ar & keysets;
|
---|
| 173 | ar & forcekeysets;
|
---|
| 174 | ar & shortrangedata;
|
---|
[adb51ab] | 175 | if (version > 0)
|
---|
| 176 | ar & cycles;
|
---|
[c8d13f5] | 177 | if (version > 1)
|
---|
| 178 | ar & summedshortrange;
|
---|
[55e1bc] | 179 | #ifdef HAVE_VMG
|
---|
| 180 | ar & longrangedata;
|
---|
| 181 | #endif
|
---|
| 182 | }
|
---|
[a3427f] | 183 | };
|
---|
| 184 |
|
---|
[adb51ab] | 185 | // version for serialized information associated to FragmentationResultContainer
|
---|
[c8d13f5] | 186 | BOOST_CLASS_VERSION(FragmentationResultContainer, 2)
|
---|
[adb51ab] | 187 |
|
---|
[a3427f] | 188 | #endif /* FRAGMENTATIONRESULTCONTAINER_HPP_ */
|
---|