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