| [ac9ca4] | 1 | /*
 | 
|---|
 | 2 |  * FragmentJobQueue.hpp
 | 
|---|
 | 3 |  *
 | 
|---|
 | 4 |  *  Created on: Mar 4, 2013
 | 
|---|
 | 5 |  *      Author: heber
 | 
|---|
 | 6 |  */
 | 
|---|
 | 7 | 
 | 
|---|
 | 8 | #ifndef FRAGMENTJOBQUEUE_HPP_
 | 
|---|
 | 9 | #define FRAGMENTJOBQUEUE_HPP_
 | 
|---|
 | 10 | 
 | 
|---|
 | 11 | // include config.h
 | 
|---|
 | 12 | #ifdef HAVE_CONFIG_H
 | 
|---|
 | 13 | #include <config.h>
 | 
|---|
 | 14 | #endif
 | 
|---|
 | 15 | 
 | 
|---|
 | 16 | #include <boost/filesystem/path.hpp>
 | 
|---|
 | 17 | #include <string>
 | 
|---|
 | 18 | #include <vector>
 | 
|---|
 | 19 | 
 | 
|---|
 | 20 | #include "CodePatterns/Singleton.hpp"
 | 
|---|
 | 21 | 
 | 
|---|
| [9445081] | 22 | #include "Fragmentation/EdgesPerFragment.hpp"
 | 
|---|
| [ac9ca4] | 23 | #include "Fragmentation/KeySetsContainer.hpp"
 | 
|---|
| [fbf143] | 24 | #include "Fragmentation/parseKeySetFile.hpp"
 | 
|---|
| [ac9ca4] | 25 | #include "Jobs/MPQCJob.hpp"
 | 
|---|
| [9445081] | 26 | #include "types.hpp"
 | 
|---|
| [ac9ca4] | 27 | 
 | 
|---|
 | 28 | /** FragmentJobQueue is a static instance to contain all present fragment
 | 
|---|
 | 29 |  * as FragmentJob's and to allow their transfer from FragmentationAction
 | 
|---|
 | 30 |  * to FragmentationAutomationAction.
 | 
|---|
 | 31 |  *
 | 
|---|
 | 32 |  * \note All contained jobs do not have yet a valid id!
 | 
|---|
 | 33 |  */
 | 
|---|
 | 34 | class FragmentJobQueue : public Singleton<FragmentJobQueue>
 | 
|---|
 | 35 | {
 | 
|---|
 | 36 |   friend class Singleton<FragmentJobQueue>;
 | 
|---|
 | 37 | private:
 | 
|---|
 | 38 |   /** Private default constructor for class FragmentJobQueue.
 | 
|---|
 | 39 |    */
 | 
|---|
 | 40 |   FragmentJobQueue()
 | 
|---|
 | 41 |   {}
 | 
|---|
 | 42 | 
 | 
|---|
 | 43 |   /** Private destructor for class FragmentJobQueue.
 | 
|---|
 | 44 |    */
 | 
|---|
 | 45 |   ~FragmentJobQueue()
 | 
|---|
 | 46 |   {}
 | 
|---|
 | 47 | 
 | 
|---|
 | 48 | public:
 | 
|---|
| [9445081] | 49 |   typedef FragmentationEdges::edges_per_fragment_t edges_per_fragment_t;
 | 
|---|
| [ac9ca4] | 50 | 
 | 
|---|
 | 51 |   /** Pushes a vector of jobs into the queue.
 | 
|---|
 | 52 |    *
 | 
|---|
 | 53 |    * \param _jobs new jobs to push
 | 
|---|
| [9445081] | 54 |    * \param _KeySet KeySet of all (non-hydrogen) atoms
 | 
|---|
 | 55 |    * \param _FullKeySet KeySet of all atoms except saturation hydrogens
 | 
|---|
 | 56 |    * \param _edges_per_fragment edges of bond graph of all fragments
 | 
|---|
| [ac9ca4] | 57 |    */
 | 
|---|
 | 58 |   void addJobs(
 | 
|---|
 | 59 |       std::vector<FragmentJob::ptr> &_jobs,
 | 
|---|
 | 60 |       const KeySetsContainer &_KeySets,
 | 
|---|
| [9445081] | 61 |       const KeySetsContainer &_FullKeySets,
 | 
|---|
 | 62 |       const edges_per_fragment_t &_edges_per_fragment);
 | 
|---|
| [ac9ca4] | 63 | 
 | 
|---|
 | 64 |   /** Returns ref to jobs.
 | 
|---|
 | 65 |    *
 | 
|---|
 | 66 |    * \param vector with all jobs
 | 
|---|
 | 67 |    */
 | 
|---|
 | 68 |   const std::vector<FragmentJob::ptr>& getJobs() const { return jobs; }
 | 
|---|
 | 69 | 
 | 
|---|
 | 70 |   /** Getter for the number of jobs contained.
 | 
|---|
 | 71 |    *
 | 
|---|
 | 72 |    * \return number of jobs in queue
 | 
|---|
 | 73 |    */
 | 
|---|
 | 74 |   size_t size() const { return jobs.size(); }
 | 
|---|
 | 75 | 
 | 
|---|
 | 76 |   /** Parses multiple files.
 | 
|---|
 | 77 |    *
 | 
|---|
 | 78 |    * \param jobfiles vector of filenames to parse
 | 
|---|
 | 79 |    * \param level level for density sampling grid
 | 
|---|
 | 80 |    */
 | 
|---|
 | 81 |   bool addJobsFromFiles(
 | 
|---|
 | 82 |       const std::vector< boost::filesystem::path > &jobfiles,
 | 
|---|
 | 83 |       const unsigned int level);
 | 
|---|
 | 84 | 
 | 
|---|
| [bae7bc] | 85 |   /** Adds keysets after fragments have been added by file.
 | 
|---|
 | 86 |    *
 | 
|---|
 | 87 |    */
 | 
|---|
 | 88 |   bool addKeySetsFromFiles(
 | 
|---|
 | 89 |       const boost::filesystem::path &path,
 | 
|---|
 | 90 |       const size_t FragmentCounter,
 | 
|---|
 | 91 |       const enum KeySetFileType keysettype
 | 
|---|
 | 92 |       );
 | 
|---|
 | 93 | 
 | 
|---|
 | 94 |   /** Adds keysets after fragments have been added by file.
 | 
|---|
 | 95 |    *
 | 
|---|
 | 96 |    */
 | 
|---|
 | 97 |   bool addFullKeySetsFromFiles(
 | 
|---|
 | 98 |       const boost::filesystem::path &path,
 | 
|---|
 | 99 |       const size_t FragmentCounter,
 | 
|---|
 | 100 |       const enum KeySetFileType keysettype
 | 
|---|
 | 101 |       );
 | 
|---|
 | 102 | 
 | 
|---|
| [9445081] | 103 |   /** Adds edges after fragments have been added by file.
 | 
|---|
 | 104 |    *
 | 
|---|
 | 105 |    */
 | 
|---|
 | 106 |   bool addEdgesPerFragmentFromFiles(
 | 
|---|
 | 107 |       const boost::filesystem::path &path
 | 
|---|
 | 108 |       );
 | 
|---|
 | 109 | 
 | 
|---|
| [ac9ca4] | 110 |   /** Getter for the container of all KeySets to the jobs.
 | 
|---|
 | 111 |    *
 | 
|---|
 | 112 |    * \return const ref to container
 | 
|---|
 | 113 |    */
 | 
|---|
 | 114 |   const KeySetsContainer& getKeySets() const { return KeySets; }
 | 
|---|
 | 115 | 
 | 
|---|
 | 116 |   /** Getter for the container of all FullKeySets to the jobs.
 | 
|---|
 | 117 |    *
 | 
|---|
 | 118 |    * \return const ref to container
 | 
|---|
 | 119 |    */
 | 
|---|
 | 120 |   const KeySetsContainer& getFullKeySets() const { return FullKeySets; }
 | 
|---|
 | 121 | 
 | 
|---|
| [9445081] | 122 |   /** Getter for the container of all edges of the bond graph over all jobs.
 | 
|---|
 | 123 |    *
 | 
|---|
 | 124 |    * \return const ref to container
 | 
|---|
 | 125 |    */
 | 
|---|
 | 126 |   const edges_per_fragment_t& getEdgesPerFragment() const { return edges_per_fragment; }
 | 
|---|
 | 127 | 
 | 
|---|
| [ac9ca4] | 128 |   /* Empties contained jobs and all KeySets.
 | 
|---|
 | 129 |    *
 | 
|---|
 | 130 |    */
 | 
|---|
 | 131 |   void clear();
 | 
|---|
 | 132 | 
 | 
|---|
 | 133 | private:
 | 
|---|
 | 134 |   /** Creates a MPQCJob with argument \a filename.
 | 
|---|
 | 135 |    *
 | 
|---|
 | 136 |    * \note job is created with invalid id.
 | 
|---|
 | 137 |    *
 | 
|---|
 | 138 |    * @param filename filename being argument to job
 | 
|---|
 | 139 |    * @param level level for density sampling grid
 | 
|---|
 | 140 |    */
 | 
|---|
 | 141 |   void parsejob(const std::string &filename, const unsigned int level);
 | 
|---|
 | 142 | 
 | 
|---|
 | 143 | private:
 | 
|---|
 | 144 |   //!> container for all present jobs
 | 
|---|
 | 145 |   std::vector<FragmentJob::ptr> jobs;
 | 
|---|
 | 146 |   //!> container for all KeySet's without hydrogens to the jobs
 | 
|---|
 | 147 |   KeySetsContainer KeySets;
 | 
|---|
 | 148 |   //!> container for all KeySet's with all except saturation hydrogen to the jobs
 | 
|---|
 | 149 |   KeySetsContainer FullKeySets;
 | 
|---|
| [9445081] | 150 |   //!> container for all edges of the bond graph of each fragments
 | 
|---|
 | 151 |   edges_per_fragment_t edges_per_fragment;
 | 
|---|
| [ac9ca4] | 152 | };
 | 
|---|
 | 153 | 
 | 
|---|
 | 154 | inline
 | 
|---|
 | 155 | void FragmentJobQueue::addJobs(
 | 
|---|
 | 156 |     std::vector<FragmentJob::ptr> &_jobs,
 | 
|---|
 | 157 |     const KeySetsContainer &_KeySets,
 | 
|---|
| [9445081] | 158 |     const KeySetsContainer &_FullKeySets,
 | 
|---|
 | 159 |     const edges_per_fragment_t &_edges_per_fragment)
 | 
|---|
| [ac9ca4] | 160 | {
 | 
|---|
 | 161 |   jobs.insert(jobs.end(), _jobs.begin(), _jobs.end());
 | 
|---|
 | 162 |   KeySets.insert(_KeySets);
 | 
|---|
 | 163 |   FullKeySets.insert(_FullKeySets);
 | 
|---|
| [9445081] | 164 |   edges_per_fragment.reserve(edges_per_fragment.size()+_edges_per_fragment.size());
 | 
|---|
 | 165 |   edges_per_fragment.insert(
 | 
|---|
 | 166 |       edges_per_fragment.end(),
 | 
|---|
 | 167 |       _edges_per_fragment.begin(), _edges_per_fragment.end());
 | 
|---|
| [ac9ca4] | 168 | }
 | 
|---|
 | 169 | 
 | 
|---|
 | 170 | #endif /* FRAGMENTJOBQUEUE_HPP_ */
 | 
|---|