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