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 |
|
---|
22 | #include "Fragmentation/KeySetsContainer.hpp"
|
---|
23 | #include "Fragmentation/Automation/parseKeySetFile.hpp"
|
---|
24 | #include "Jobs/MPQCJob.hpp"
|
---|
25 |
|
---|
26 | /** FragmentJobQueue is a static instance to contain all present fragment
|
---|
27 | * as FragmentJob's and to allow their transfer from FragmentationAction
|
---|
28 | * to FragmentationAutomationAction.
|
---|
29 | *
|
---|
30 | * \note All contained jobs do not have yet a valid id!
|
---|
31 | */
|
---|
32 | class FragmentJobQueue : public Singleton<FragmentJobQueue>
|
---|
33 | {
|
---|
34 | friend class Singleton<FragmentJobQueue>;
|
---|
35 | private:
|
---|
36 | /** Private default constructor for class FragmentJobQueue.
|
---|
37 | */
|
---|
38 | FragmentJobQueue()
|
---|
39 | {}
|
---|
40 |
|
---|
41 | /** Private destructor for class FragmentJobQueue.
|
---|
42 | */
|
---|
43 | ~FragmentJobQueue()
|
---|
44 | {}
|
---|
45 |
|
---|
46 | public:
|
---|
47 |
|
---|
48 | /** Pushes a vector of jobs into the queue.
|
---|
49 | *
|
---|
50 | * \param _jobs new jobs to push
|
---|
51 | * \param KeySet KeySet of all (non-hydrogen) atoms
|
---|
52 | * \param FullKeySet KeySet of all atoms except saturation hydrogens
|
---|
53 | */
|
---|
54 | void addJobs(
|
---|
55 | std::vector<FragmentJob::ptr> &_jobs,
|
---|
56 | const KeySetsContainer &_KeySets,
|
---|
57 | const KeySetsContainer &_FullKeySets);
|
---|
58 |
|
---|
59 | /** Returns ref to jobs.
|
---|
60 | *
|
---|
61 | * \param vector with all jobs
|
---|
62 | */
|
---|
63 | const std::vector<FragmentJob::ptr>& getJobs() const { return jobs; }
|
---|
64 |
|
---|
65 | /** Getter for the number of jobs contained.
|
---|
66 | *
|
---|
67 | * \return number of jobs in queue
|
---|
68 | */
|
---|
69 | size_t size() const { return jobs.size(); }
|
---|
70 |
|
---|
71 | /** Parses multiple files.
|
---|
72 | *
|
---|
73 | * \param jobfiles vector of filenames to parse
|
---|
74 | * \param level level for density sampling grid
|
---|
75 | */
|
---|
76 | bool addJobsFromFiles(
|
---|
77 | const std::vector< boost::filesystem::path > &jobfiles,
|
---|
78 | const unsigned int level);
|
---|
79 |
|
---|
80 | /** Adds keysets after fragments have been added by file.
|
---|
81 | *
|
---|
82 | */
|
---|
83 | bool addKeySetsFromFiles(
|
---|
84 | const boost::filesystem::path &path,
|
---|
85 | const size_t FragmentCounter,
|
---|
86 | const enum KeySetFileType keysettype
|
---|
87 | );
|
---|
88 |
|
---|
89 | /** Adds keysets after fragments have been added by file.
|
---|
90 | *
|
---|
91 | */
|
---|
92 | bool addFullKeySetsFromFiles(
|
---|
93 | const boost::filesystem::path &path,
|
---|
94 | const size_t FragmentCounter,
|
---|
95 | const enum KeySetFileType keysettype
|
---|
96 | );
|
---|
97 |
|
---|
98 | /** Getter for the container of all KeySets to the jobs.
|
---|
99 | *
|
---|
100 | * \return const ref to container
|
---|
101 | */
|
---|
102 | const KeySetsContainer& getKeySets() const { return KeySets; }
|
---|
103 |
|
---|
104 | /** Getter for the container of all FullKeySets to the jobs.
|
---|
105 | *
|
---|
106 | * \return const ref to container
|
---|
107 | */
|
---|
108 | const KeySetsContainer& getFullKeySets() const { return FullKeySets; }
|
---|
109 |
|
---|
110 | /* Empties contained jobs and all KeySets.
|
---|
111 | *
|
---|
112 | */
|
---|
113 | void clear();
|
---|
114 |
|
---|
115 | private:
|
---|
116 | /** Creates a MPQCJob with argument \a filename.
|
---|
117 | *
|
---|
118 | * \note job is created with invalid id.
|
---|
119 | *
|
---|
120 | * @param filename filename being argument to job
|
---|
121 | * @param level level for density sampling grid
|
---|
122 | */
|
---|
123 | void parsejob(const std::string &filename, const unsigned int level);
|
---|
124 |
|
---|
125 | private:
|
---|
126 | //!> container for all present jobs
|
---|
127 | std::vector<FragmentJob::ptr> jobs;
|
---|
128 | //!> container for all KeySet's without hydrogens to the jobs
|
---|
129 | KeySetsContainer KeySets;
|
---|
130 | //!> container for all KeySet's with all except saturation hydrogen to the jobs
|
---|
131 | KeySetsContainer FullKeySets;
|
---|
132 | };
|
---|
133 |
|
---|
134 | inline
|
---|
135 | void FragmentJobQueue::addJobs(
|
---|
136 | std::vector<FragmentJob::ptr> &_jobs,
|
---|
137 | const KeySetsContainer &_KeySets,
|
---|
138 | const KeySetsContainer &_FullKeySets)
|
---|
139 | {
|
---|
140 | jobs.insert(jobs.end(), _jobs.begin(), _jobs.end());
|
---|
141 | KeySets.insert(_KeySets);
|
---|
142 | FullKeySets.insert(_FullKeySets);
|
---|
143 | }
|
---|
144 |
|
---|
145 | #endif /* FRAGMENTJOBQUEUE_HPP_ */
|
---|