| [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>
 | 
|---|
| [a2a2f7] | 17 | #include <boost/serialization/map.hpp>
 | 
|---|
 | 18 | #include <boost/serialization/split_member.hpp>
 | 
|---|
 | 19 | #include <boost/serialization/version.hpp>
 | 
|---|
| [a3427f] | 20 | #include "CodePatterns/Singleton.hpp"
 | 
|---|
 | 21 | 
 | 
|---|
| [55e1bc] | 22 | #include <boost/filesystem/path.hpp>
 | 
|---|
| [a3427f] | 23 | #include <map>
 | 
|---|
 | 24 | 
 | 
|---|
| [d20ded] | 25 | #include "CodePatterns/Observer/Observable.hpp"
 | 
|---|
 | 26 | 
 | 
|---|
| [a3427f] | 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"
 | 
|---|
| [c8d13f5] | 34 | #include "Fragmentation/Summation/IndexSet.hpp"
 | 
|---|
 | 35 | #include "Fragmentation/Summation/Containers/FragmentationShortRangeResults.hpp"
 | 
|---|
| [a3427f] | 36 | #include "Fragmentation/Summation/Containers/MPQCData.hpp"
 | 
|---|
| [c8d13f5] | 37 | #include "Fragmentation/Summation/Containers/MPQCDataMap.hpp"
 | 
|---|
| [18ed8c] | 38 | #if defined(HAVE_JOBMARKET) && defined(HAVE_VMG)
 | 
|---|
| [a3427f] | 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
 | 
|---|
| [55e1bc] | 46 |  * results in between. Hence, we place results into this container which we may
 | 
|---|
 | 47 |  * full serialize.
 | 
|---|
| [a3427f] | 48 |  */
 | 
|---|
| [d20ded] | 49 | class FragmentationResultContainer :
 | 
|---|
 | 50 |     public Singleton<FragmentationResultContainer>,
 | 
|---|
 | 51 |     public Observable
 | 
|---|
| [a3427f] | 52 | {
 | 
|---|
 | 53 |   //!> Singleton patterns needs access to private cstor/dtor.
 | 
|---|
 | 54 |   friend class Singleton<FragmentationResultContainer>;
 | 
|---|
 | 55 | private:
 | 
|---|
 | 56 |   FragmentationResultContainer() :
 | 
|---|
| [d20ded] | 57 |     Observable("FragmentationResultContainer"),
 | 
|---|
| [a3427f] | 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;
 | 
|---|
| [18ed8c] | 65 | #if defined(HAVE_JOBMARKET) && defined(HAVE_VMG)
 | 
|---|
| [a3427f] | 66 |   //!> typedef for long range data container
 | 
|---|
 | 67 |   typedef std::map<JobId_t, VMGData> longrangedata_t;
 | 
|---|
 | 68 | #endif
 | 
|---|
 | 69 | 
 | 
|---|
| [18ed8c] | 70 | #if defined(HAVE_JOBMARKET) && defined(HAVE_VMG)
 | 
|---|
| [a3427f] | 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
 | 
|---|
| [adb51ab] | 76 |    * \param _forcekeysetskeysets
 | 
|---|
| [a3427f] | 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 | 
 | 
|---|
| [c8d13f5] | 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 | 
 | 
|---|
| [adb51ab] | 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 | 
 | 
|---|
| [a3427f] | 119 |   /** Clears all internal containers.
 | 
|---|
 | 120 |    *
 | 
|---|
 | 121 |    * \note Also resets ResultsType.
 | 
|---|
 | 122 |    */
 | 
|---|
 | 123 |   void clear()
 | 
|---|
 | 124 |   {
 | 
|---|
| [d20ded] | 125 |     OBSERVE;
 | 
|---|
| [a3427f] | 126 |     keysets.clear();
 | 
|---|
 | 127 |     forcekeysets.clear();
 | 
|---|
| [f83e26] | 128 |     cycles.clear();
 | 
|---|
| [a3427f] | 129 |     shortrangedata.clear();
 | 
|---|
| [c8d13f5] | 130 |     summedshortrange.clear();
 | 
|---|
| [18ed8c] | 131 | #if defined(HAVE_JOBMARKET) && defined(HAVE_VMG)
 | 
|---|
| [a3427f] | 132 |     longrangedata.clear();
 | 
|---|
 | 133 | #endif
 | 
|---|
 | 134 |     ResultsType = BothRanges;
 | 
|---|
 | 135 |   }
 | 
|---|
 | 136 | 
 | 
|---|
 | 137 |   const KeySetsContainer &getKeySets() const { return keysets; }
 | 
|---|
| [adb51ab] | 138 |   const KeySetsContainer &getCycles() const { return cycles; }
 | 
|---|
| [a3427f] | 139 |   const KeySetsContainer &getForceKeySets() const  { return forcekeysets; }
 | 
|---|
 | 140 |   const shortrangedata_t& getShortRangeResults() const  { return shortrangedata; }
 | 
|---|
| [c8d13f5] | 141 |   const FragmentationShortRangeResults::summedshortrange_t& getShortRangeSummedResults() const  { return summedshortrange; }
 | 
|---|
| [18ed8c] | 142 | #if defined(HAVE_JOBMARKET) && defined(HAVE_VMG)
 | 
|---|
| [a3427f] | 143 |   const longrangedata_t& getLongRangeResults() const;
 | 
|---|
 | 144 | #endif
 | 
|---|
 | 145 |   bool areFullRangeResultsPresent() const { return (ResultsType == BothRanges); }
 | 
|---|
 | 146 | 
 | 
|---|
 | 147 | private:
 | 
|---|
 | 148 |   //!> indicates whether we contain short range only or both results
 | 
|---|
 | 149 |   enum ResultsType_t {
 | 
|---|
 | 150 |     ShortRangeOnly,
 | 
|---|
 | 151 |     BothRanges,
 | 
|---|
 | 152 |   } ResultsType;
 | 
|---|
 | 153 | 
 | 
|---|
 | 154 |   //!> container for all KeySet's without hydrogens to the jobs
 | 
|---|
 | 155 |   KeySetsContainer keysets;
 | 
|---|
 | 156 |   //!> container for all KeySet's with all except saturation hydrogen to the jobs
 | 
|---|
 | 157 |   KeySetsContainer forcekeysets;
 | 
|---|
 | 158 |   //!> container for all short-range results
 | 
|---|
 | 159 |   std::map<JobId_t, MPQCData> shortrangedata;
 | 
|---|
| [adb51ab] | 160 |   //! container of all cycle keysets
 | 
|---|
 | 161 |   KeySetsContainer cycles;
 | 
|---|
| [c8d13f5] | 162 |   //!> container for summed up results per index set
 | 
|---|
 | 163 |   FragmentationShortRangeResults::summedshortrange_t summedshortrange;
 | 
|---|
| [a3427f] | 164 | 
 | 
|---|
| [18ed8c] | 165 | #if defined(HAVE_JOBMARKET) && defined(HAVE_VMG)
 | 
|---|
| [a3427f] | 166 |   //!> container for all long-range results
 | 
|---|
 | 167 |   std::map<JobId_t, VMGData> longrangedata;
 | 
|---|
 | 168 | #endif
 | 
|---|
| [55e1bc] | 169 | 
 | 
|---|
 | 170 |   friend class boost::serialization::access;
 | 
|---|
 | 171 |   // serialization
 | 
|---|
 | 172 |   template <typename Archive>
 | 
|---|
| [a2a2f7] | 173 |   void load(Archive& ar, const unsigned int version)
 | 
|---|
 | 174 |   {
 | 
|---|
 | 175 |     OBSERVE;
 | 
|---|
 | 176 |     ar & ResultsType;
 | 
|---|
 | 177 |     ar & keysets;
 | 
|---|
 | 178 |     ar & forcekeysets;
 | 
|---|
 | 179 |     ar & shortrangedata;
 | 
|---|
 | 180 |     if (version > 0)
 | 
|---|
 | 181 |       ar & cycles;
 | 
|---|
 | 182 |     if (version > 1)
 | 
|---|
 | 183 |       ar & summedshortrange;
 | 
|---|
| [18ed8c] | 184 | #if defined(HAVE_JOBMARKET) && defined(HAVE_VMG)
 | 
|---|
| [a2a2f7] | 185 |     ar & longrangedata;
 | 
|---|
 | 186 | #endif
 | 
|---|
 | 187 |   }
 | 
|---|
 | 188 |   template <typename Archive>
 | 
|---|
 | 189 |   void save(Archive& ar, const unsigned int version) const
 | 
|---|
| [55e1bc] | 190 |   {
 | 
|---|
 | 191 |     ar & ResultsType;
 | 
|---|
 | 192 |     ar & keysets;
 | 
|---|
 | 193 |     ar & forcekeysets;
 | 
|---|
 | 194 |     ar & shortrangedata;
 | 
|---|
| [adb51ab] | 195 |     if (version > 0)
 | 
|---|
 | 196 |       ar & cycles;
 | 
|---|
| [c8d13f5] | 197 |     if (version > 1)
 | 
|---|
 | 198 |       ar & summedshortrange;
 | 
|---|
| [18ed8c] | 199 | #if defined(HAVE_JOBMARKET) && defined(HAVE_VMG)
 | 
|---|
| [55e1bc] | 200 |     ar & longrangedata;
 | 
|---|
 | 201 | #endif
 | 
|---|
 | 202 |   }
 | 
|---|
| [a2a2f7] | 203 |   BOOST_SERIALIZATION_SPLIT_MEMBER()
 | 
|---|
| [a3427f] | 204 | };
 | 
|---|
 | 205 | 
 | 
|---|
| [adb51ab] | 206 | // version for serialized information associated to FragmentationResultContainer
 | 
|---|
| [c8d13f5] | 207 | BOOST_CLASS_VERSION(FragmentationResultContainer, 2)
 | 
|---|
| [adb51ab] | 208 | 
 | 
|---|
| [a3427f] | 209 | #endif /* FRAGMENTATIONRESULTCONTAINER_HPP_ */
 | 
|---|