source: src/Fragmentation/Summation/Containers/FragmentationResultContainer.hpp

Candidate_v1.6.1
Last change on this file was ea63cb, checked in by Frederik Heber <heber@…>, 8 years ago

Edges per Fragment passed on to FragmentationShortRangeResults.

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