source: src/Fragmentation/Automation/MPQCCommandFragmentController.hpp@ 019b96

Last change on this file since 019b96 was 019b96, checked in by Frederik Heber <heber@…>, 11 years ago

SystemCommandJob now allows for resetting the command in derived classes.

  • command is just protected.
  • MPQCCommandJob::resetCommand() allows overwrite to MPQCCommandFragmentController.
  • MPQCCommandFragmentController::addJobsFromQueue() allows setting of new command.
  • FragmentationAutomationAction::performCalls() sets params.executable.
  • Property mode set to 100644
File size: 2.9 KB
Line 
1/*
2 * MPQCCommandFragmentController.hpp
3 *
4 * Created on: Apr 14, 2014
5 * Author: heber
6 */
7
8#ifndef MPQCCOMMANDFRAGMENTCONTROLLER_HPP_
9#define MPQCCOMMANDFRAGMENTCONTROLLER_HPP_
10
11
12// include config.h
13#ifdef HAVE_CONFIG_H
14#include <config.h>
15#endif
16
17#include <boost/filesystem/path.hpp>
18#include <boost/function.hpp>
19
20#include <list>
21#include <map>
22#include <string>
23#include <vector>
24
25#include "Fragmentation/Summation/Containers/MPQCData.hpp"
26#include "Fragmentation/Automation/ResultContainer.hpp"
27
28/** This class mimics the interface of SpecificFragmentController derived from
29 * JobMarket's FragmentController but without using JobMarket.
30 *
31 * This is for calculating fragments via MPQCCommandJobs when JobMarket is not
32 * available.
33 */
34class MPQCCommandFragmentController
35{
36public:
37 MPQCCommandFragmentController() :
38 exitflag(0)
39 {}
40 ~MPQCCommandFragmentController()
41 {}
42
43 typedef boost::function<void (const size_t,const size_t)> update_handler_t;
44
45 void setUpdateHandler(update_handler_t _handler)
46 {
47 handler = _handler;
48 }
49
50 /** Command Controller to fill its hold of jobs from FragmentJobQueue.
51 *
52 * \param _command command to execute
53 * \param _DoSampleDensity whether to actually sample the resulting electronic density
54 * \param _DoValenceOnly whether to sample just the valence or the total elctron and nuclei density
55 * \param _command command to pass to jobs for execution
56 * \return true - jobs obtained, false - queue empty
57 */
58 bool addJobsFromQueue(
59 const std::string _command,
60 const MPQCData::DoLongrange_t _DoLongrange,
61 const MPQCData::DoValenceOnly_t _DoValenceOnly,
62 const std::string &_command
63 );
64
65 /** Mimicks waitforResults but actually does nothing.
66 *
67 */
68 void waitforResults(const size_t NoExpectedResults)
69 { return; }
70
71 /** Get results map of calculated jobs.
72 *
73 * \param fragmentData contains map of results on output
74 */
75 void getResults(std::map<JobId_t, MPQCData> &fragmentData) {
76 fragmentData.insert(results.IdData.begin(), results.IdData.end());
77 results.clear();
78 }
79
80 /** Runs the service.
81 *
82 * Here, we finalize each job's id and push them to the server.
83 */
84 void run();
85
86 /** Mimicks a (unlimited) pool of requested ids that are served by this function.
87 *
88 * \return next unique job id to use
89 */
90 unsigned int getAvailableId()
91 {
92 return nextid++;
93 }
94
95 /** Getter for exitflag.
96 *
97 * \return exitflag
98 */
99 int getExitflag() const
100 { return exitflag; }
101
102private:
103 //!> static member variable to count individual job ids
104 static unsigned int nextid;
105
106 //!> overall exit flag of jobs
107 int exitflag;
108
109 //!> queue with all jobs to calculate serially
110 std::list<MPQCCommandJob *> queue;
111
112 //!> type-specific result container
113 ResultContainer<MPQCData> results;
114
115 //!> update handler that is called in waitforResults()
116 update_handler_t handler;
117};
118
119
120#endif /* MPQCCOMMANDFRAGMENTCONTROLLER_HPP_ */
Note: See TracBrowser for help on using the repository browser.