[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"
|
---|
| 31 | #include "Fragmentation/Summation/Containers/MPQCData.hpp"
|
---|
| 32 | #ifdef HAVE_VMG
|
---|
| 33 | #include "Fragmentation/Summation/Containers/VMGData.hpp"
|
---|
| 34 | #endif
|
---|
| 35 |
|
---|
| 36 | /** This class stores results from lengthy fragmentation calculations, e.g.
|
---|
| 37 | * coming out of FragmentationAutomationAction.
|
---|
| 38 | *
|
---|
| 39 | * The idea is that we can play around with results without having to recalculate
|
---|
[55e1bc] | 40 | * results in between. Hence, we place results into this container which we may
|
---|
| 41 | * full serialize.
|
---|
[a3427f] | 42 | */
|
---|
[d20ded] | 43 | class FragmentationResultContainer :
|
---|
| 44 | public Singleton<FragmentationResultContainer>,
|
---|
| 45 | public Observable
|
---|
[a3427f] | 46 | {
|
---|
| 47 | //!> Singleton patterns needs access to private cstor/dtor.
|
---|
| 48 | friend class Singleton<FragmentationResultContainer>;
|
---|
| 49 | private:
|
---|
| 50 | FragmentationResultContainer() :
|
---|
[d20ded] | 51 | Observable("FragmentationResultContainer"),
|
---|
[a3427f] | 52 | ResultsType(BothRanges)
|
---|
| 53 | {}
|
---|
| 54 | ~FragmentationResultContainer() {}
|
---|
| 55 |
|
---|
| 56 | public:
|
---|
| 57 | //!> typedef for short range data container
|
---|
| 58 | typedef std::map<JobId_t, MPQCData> shortrangedata_t;
|
---|
| 59 | #ifdef HAVE_VMG
|
---|
| 60 | //!> typedef for long range data container
|
---|
| 61 | typedef std::map<JobId_t, VMGData> longrangedata_t;
|
---|
| 62 | #endif
|
---|
| 63 |
|
---|
| 64 | #ifdef HAVE_VMG
|
---|
| 65 | /** Adds a a set of both short and long range results.
|
---|
| 66 | *
|
---|
| 67 | * Adds all the containers to the ones present in this instance.
|
---|
| 68 | *
|
---|
| 69 | * \param _keysets
|
---|
| 70 | * \param _forcekeysets
|
---|
| 71 | * \param _shortrangedata
|
---|
| 72 | * \param _longrangedata
|
---|
| 73 | */
|
---|
| 74 | void addFullResults(
|
---|
| 75 | const KeySetsContainer &_keysets,
|
---|
| 76 | const KeySetsContainer &_forcekeysets,
|
---|
| 77 | const shortrangedata_t &_shortrangedata,
|
---|
| 78 | const longrangedata_t &_longrangedata
|
---|
| 79 | );
|
---|
| 80 | #endif
|
---|
| 81 |
|
---|
| 82 | /** Adds a a set of short range results only.
|
---|
| 83 | *
|
---|
| 84 | * Adds all the containers to the ones present in this instance.
|
---|
| 85 | *
|
---|
| 86 | * \param _keysets
|
---|
| 87 | * \param _forcekeysets
|
---|
| 88 | * \param _shortrangedata
|
---|
| 89 | */
|
---|
| 90 | void addShortRangeResults(
|
---|
| 91 | const KeySetsContainer &_keysets,
|
---|
| 92 | const KeySetsContainer &_forcekeysets,
|
---|
| 93 | const shortrangedata_t &_shortrangedata
|
---|
| 94 | );
|
---|
| 95 |
|
---|
| 96 | /** Clears all internal containers.
|
---|
| 97 | *
|
---|
| 98 | * \note Also resets ResultsType.
|
---|
| 99 | */
|
---|
| 100 | void clear()
|
---|
| 101 | {
|
---|
[d20ded] | 102 | OBSERVE;
|
---|
[a3427f] | 103 | keysets.clear();
|
---|
| 104 | forcekeysets.clear();
|
---|
| 105 | shortrangedata.clear();
|
---|
| 106 | #ifdef HAVE_VMG
|
---|
| 107 | longrangedata.clear();
|
---|
| 108 | #endif
|
---|
| 109 | ResultsType = BothRanges;
|
---|
| 110 | }
|
---|
| 111 |
|
---|
| 112 | const KeySetsContainer &getKeySets() const { return keysets; }
|
---|
| 113 | const KeySetsContainer &getForceKeySets() const { return forcekeysets; }
|
---|
| 114 | const shortrangedata_t& getShortRangeResults() const { return shortrangedata; }
|
---|
| 115 | #ifdef HAVE_VMG
|
---|
| 116 | const longrangedata_t& getLongRangeResults() const;
|
---|
| 117 | #endif
|
---|
| 118 | bool areFullRangeResultsPresent() const { return (ResultsType == BothRanges); }
|
---|
| 119 |
|
---|
| 120 | private:
|
---|
| 121 | //!> indicates whether we contain short range only or both results
|
---|
| 122 | enum ResultsType_t {
|
---|
| 123 | ShortRangeOnly,
|
---|
| 124 | BothRanges,
|
---|
| 125 | } ResultsType;
|
---|
| 126 |
|
---|
| 127 | //!> container for all KeySet's without hydrogens to the jobs
|
---|
| 128 | KeySetsContainer keysets;
|
---|
| 129 | //!> container for all KeySet's with all except saturation hydrogen to the jobs
|
---|
| 130 | KeySetsContainer forcekeysets;
|
---|
| 131 | //!> container for all short-range results
|
---|
| 132 | std::map<JobId_t, MPQCData> shortrangedata;
|
---|
| 133 |
|
---|
| 134 | #ifdef HAVE_VMG
|
---|
| 135 | //!> container for all long-range results
|
---|
| 136 | std::map<JobId_t, VMGData> longrangedata;
|
---|
| 137 | #endif
|
---|
[55e1bc] | 138 |
|
---|
| 139 | friend class boost::serialization::access;
|
---|
| 140 | // serialization
|
---|
| 141 | template <typename Archive>
|
---|
| 142 | void serialize(Archive& ar, const unsigned int version)
|
---|
| 143 | {
|
---|
| 144 | ar & ResultsType;
|
---|
| 145 | ar & keysets;
|
---|
| 146 | ar & forcekeysets;
|
---|
| 147 | ar & shortrangedata;
|
---|
| 148 | #ifdef HAVE_VMG
|
---|
| 149 | ar & longrangedata;
|
---|
| 150 | #endif
|
---|
| 151 | }
|
---|
[a3427f] | 152 | };
|
---|
| 153 |
|
---|
| 154 | #endif /* FRAGMENTATIONRESULTCONTAINER_HPP_ */
|
---|