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 |
|
---|
16 | #include <boost/serialization/access.hpp>
|
---|
17 | #include <boost/serialization/map.hpp>
|
---|
18 | #include <boost/serialization/split_member.hpp>
|
---|
19 | #include <boost/serialization/version.hpp>
|
---|
20 | #include "CodePatterns/Singleton.hpp"
|
---|
21 |
|
---|
22 | #include <boost/filesystem/path.hpp>
|
---|
23 | #include <map>
|
---|
24 |
|
---|
25 | #include "CodePatterns/Observer/Observable.hpp"
|
---|
26 |
|
---|
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"
|
---|
34 | #include "Fragmentation/Summation/IndexSet.hpp"
|
---|
35 | #include "Fragmentation/Summation/Containers/FragmentationShortRangeResults.hpp"
|
---|
36 | #include "Fragmentation/Summation/Containers/MPQCData.hpp"
|
---|
37 | #include "Fragmentation/Summation/Containers/MPQCDataMap.hpp"
|
---|
38 | #if defined(HAVE_JOBMARKET) && defined(HAVE_VMG)
|
---|
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
|
---|
46 | * results in between. Hence, we place results into this container which we may
|
---|
47 | * full serialize.
|
---|
48 | */
|
---|
49 | class FragmentationResultContainer :
|
---|
50 | public Singleton<FragmentationResultContainer>,
|
---|
51 | public Observable
|
---|
52 | {
|
---|
53 | //!> Singleton patterns needs access to private cstor/dtor.
|
---|
54 | friend class Singleton<FragmentationResultContainer>;
|
---|
55 | private:
|
---|
56 | FragmentationResultContainer() :
|
---|
57 | Observable("FragmentationResultContainer"),
|
---|
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;
|
---|
65 | #if defined(HAVE_JOBMARKET) && defined(HAVE_VMG)
|
---|
66 | //!> typedef for long range data container
|
---|
67 | typedef std::map<JobId_t, VMGData> longrangedata_t;
|
---|
68 | #endif
|
---|
69 |
|
---|
70 | #if defined(HAVE_JOBMARKET) && defined(HAVE_VMG)
|
---|
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
|
---|
76 | * \param _forcekeysetskeysets
|
---|
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 |
|
---|
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 |
|
---|
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 |
|
---|
119 | /** Clears all internal containers.
|
---|
120 | *
|
---|
121 | * \note Also resets ResultsType.
|
---|
122 | */
|
---|
123 | void clear()
|
---|
124 | {
|
---|
125 | OBSERVE;
|
---|
126 | keysets.clear();
|
---|
127 | forcekeysets.clear();
|
---|
128 | shortrangedata.clear();
|
---|
129 | summedshortrange.clear();
|
---|
130 | #if defined(HAVE_JOBMARKET) && defined(HAVE_VMG)
|
---|
131 | longrangedata.clear();
|
---|
132 | #endif
|
---|
133 | ResultsType = BothRanges;
|
---|
134 | }
|
---|
135 |
|
---|
136 | const KeySetsContainer &getKeySets() const { return keysets; }
|
---|
137 | const KeySetsContainer &getCycles() const { return cycles; }
|
---|
138 | const KeySetsContainer &getForceKeySets() const { return forcekeysets; }
|
---|
139 | const shortrangedata_t& getShortRangeResults() const { return shortrangedata; }
|
---|
140 | const FragmentationShortRangeResults::summedshortrange_t& getShortRangeSummedResults() const { return summedshortrange; }
|
---|
141 | #if defined(HAVE_JOBMARKET) && defined(HAVE_VMG)
|
---|
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;
|
---|
159 | //! container of all cycle keysets
|
---|
160 | KeySetsContainer cycles;
|
---|
161 | //!> container for summed up results per index set
|
---|
162 | FragmentationShortRangeResults::summedshortrange_t summedshortrange;
|
---|
163 |
|
---|
164 | #if defined(HAVE_JOBMARKET) && defined(HAVE_VMG)
|
---|
165 | //!> container for all long-range results
|
---|
166 | std::map<JobId_t, VMGData> longrangedata;
|
---|
167 | #endif
|
---|
168 |
|
---|
169 | friend class boost::serialization::access;
|
---|
170 | // serialization
|
---|
171 | template <typename Archive>
|
---|
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;
|
---|
183 | #if defined(HAVE_JOBMARKET) && defined(HAVE_VMG)
|
---|
184 | ar & longrangedata;
|
---|
185 | #endif
|
---|
186 | }
|
---|
187 | template <typename Archive>
|
---|
188 | void save(Archive& ar, const unsigned int version) const
|
---|
189 | {
|
---|
190 | ar & ResultsType;
|
---|
191 | ar & keysets;
|
---|
192 | ar & forcekeysets;
|
---|
193 | ar & shortrangedata;
|
---|
194 | if (version > 0)
|
---|
195 | ar & cycles;
|
---|
196 | if (version > 1)
|
---|
197 | ar & summedshortrange;
|
---|
198 | #if defined(HAVE_JOBMARKET) && defined(HAVE_VMG)
|
---|
199 | ar & longrangedata;
|
---|
200 | #endif
|
---|
201 | }
|
---|
202 | BOOST_SERIALIZATION_SPLIT_MEMBER()
|
---|
203 | };
|
---|
204 |
|
---|
205 | // version for serialized information associated to FragmentationResultContainer
|
---|
206 | BOOST_CLASS_VERSION(FragmentationResultContainer, 2)
|
---|
207 |
|
---|
208 | #endif /* FRAGMENTATIONRESULTCONTAINER_HPP_ */
|
---|