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 "CodePatterns/Singleton.hpp"
|
---|
18 |
|
---|
19 | #include <boost/filesystem/path.hpp>
|
---|
20 | #include <map>
|
---|
21 |
|
---|
22 | #include "CodePatterns/Observer/Observable.hpp"
|
---|
23 |
|
---|
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
|
---|
40 | * results in between. Hence, we place results into this container which we may
|
---|
41 | * full serialize.
|
---|
42 | */
|
---|
43 | class FragmentationResultContainer :
|
---|
44 | public Singleton<FragmentationResultContainer>,
|
---|
45 | public Observable
|
---|
46 | {
|
---|
47 | //!> Singleton patterns needs access to private cstor/dtor.
|
---|
48 | friend class Singleton<FragmentationResultContainer>;
|
---|
49 | private:
|
---|
50 | FragmentationResultContainer() :
|
---|
51 | Observable("FragmentationResultContainer"),
|
---|
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 _forcekeysetskeysets
|
---|
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 | /** Adds given cycles to internal keyset list.
|
---|
97 | *
|
---|
98 | * \param _cycles keysets of cycles to add
|
---|
99 | */
|
---|
100 | void addCycles(const KeySetsContainer &_cycles)
|
---|
101 | { cycles.insert(_cycles); }
|
---|
102 |
|
---|
103 | /** Clears all internal containers.
|
---|
104 | *
|
---|
105 | * \note Also resets ResultsType.
|
---|
106 | */
|
---|
107 | void clear()
|
---|
108 | {
|
---|
109 | OBSERVE;
|
---|
110 | keysets.clear();
|
---|
111 | forcekeysets.clear();
|
---|
112 | shortrangedata.clear();
|
---|
113 | #ifdef HAVE_VMG
|
---|
114 | longrangedata.clear();
|
---|
115 | #endif
|
---|
116 | ResultsType = BothRanges;
|
---|
117 | }
|
---|
118 |
|
---|
119 | const KeySetsContainer &getKeySets() const { return keysets; }
|
---|
120 | const KeySetsContainer &getCycles() const { return cycles; }
|
---|
121 | const KeySetsContainer &getForceKeySets() const { return forcekeysets; }
|
---|
122 | const shortrangedata_t& getShortRangeResults() const { return shortrangedata; }
|
---|
123 | #ifdef HAVE_VMG
|
---|
124 | const longrangedata_t& getLongRangeResults() const;
|
---|
125 | #endif
|
---|
126 | bool areFullRangeResultsPresent() const { return (ResultsType == BothRanges); }
|
---|
127 |
|
---|
128 | private:
|
---|
129 | //!> indicates whether we contain short range only or both results
|
---|
130 | enum ResultsType_t {
|
---|
131 | ShortRangeOnly,
|
---|
132 | BothRanges,
|
---|
133 | } ResultsType;
|
---|
134 |
|
---|
135 | //!> container for all KeySet's without hydrogens to the jobs
|
---|
136 | KeySetsContainer keysets;
|
---|
137 | //!> container for all KeySet's with all except saturation hydrogen to the jobs
|
---|
138 | KeySetsContainer forcekeysets;
|
---|
139 | //!> container for all short-range results
|
---|
140 | std::map<JobId_t, MPQCData> shortrangedata;
|
---|
141 | //! container of all cycle keysets
|
---|
142 | KeySetsContainer cycles;
|
---|
143 |
|
---|
144 | #ifdef HAVE_VMG
|
---|
145 | //!> container for all long-range results
|
---|
146 | std::map<JobId_t, VMGData> longrangedata;
|
---|
147 | #endif
|
---|
148 |
|
---|
149 | friend class boost::serialization::access;
|
---|
150 | // serialization
|
---|
151 | template <typename Archive>
|
---|
152 | void serialize(Archive& ar, const unsigned int version)
|
---|
153 | {
|
---|
154 | ar & ResultsType;
|
---|
155 | ar & keysets;
|
---|
156 | ar & forcekeysets;
|
---|
157 | ar & shortrangedata;
|
---|
158 | if (version > 0)
|
---|
159 | ar & cycles;
|
---|
160 | #ifdef HAVE_VMG
|
---|
161 | ar & longrangedata;
|
---|
162 | #endif
|
---|
163 | }
|
---|
164 | };
|
---|
165 |
|
---|
166 | // version for serialized information associated to FragmentationResultContainer
|
---|
167 | BOOST_CLASS_VERSION(FragmentationResultContainer, 1)
|
---|
168 |
|
---|
169 | #endif /* FRAGMENTATIONRESULTCONTAINER_HPP_ */
|
---|