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