source: src/Fragmentation/Automation/SpecificFragmentController.hpp@ 2199c2

Action_Thermostats Add_AtomRandomPerturbation Add_FitFragmentPartialChargesAction Add_RotateAroundBondAction Add_SelectAtomByNameAction Adding_Graph_to_ChangeBondActions Adding_MD_integration_tests Adding_StructOpt_integration_tests Automaking_mpqc_open AutomationFragmentation_failures Candidate_v1.5.4 Candidate_v1.6.0 Candidate_v1.6.1 ChangeBugEmailaddress ChangingTestPorts ChemicalSpaceEvaluator Combining_Subpackages Debian_Package_split Debian_package_split_molecuildergui_only Disabling_MemDebug Docu_Python_wait EmpiricalPotential_contain_HomologyGraph EmpiricalPotential_contain_HomologyGraph_documentation Enable_parallel_make_install Enhance_userguide Enhanced_StructuralOptimization Enhanced_StructuralOptimization_continued Example_ManyWaysToTranslateAtom Exclude_Hydrogens_annealWithBondGraph FitPartialCharges_GlobalError Fix_ChargeSampling_PBC Fix_ChronosMutex Fix_FitPartialCharges Fix_FitPotential_needs_atomicnumbers Fix_ForceAnnealing Fix_IndependentFragmentGrids Fix_ParseParticles Fix_ParseParticles_split_forward_backward_Actions Fix_StatusMsg Fix_StepWorldTime_single_argument Fix_Verbose_Codepatterns ForceAnnealing_goodresults ForceAnnealing_oldresults ForceAnnealing_tocheck ForceAnnealing_with_BondGraph ForceAnnealing_with_BondGraph_continued ForceAnnealing_with_BondGraph_continued_betteresults ForceAnnealing_with_BondGraph_contraction-expansion GeometryObjects Gui_displays_atomic_force_velocity IndependentFragmentGrids IndependentFragmentGrids_IndividualZeroInstances IndependentFragmentGrids_IntegrationTest IndependentFragmentGrids_Sole_NN_Calculation JobMarket_RobustOnKillsSegFaults JobMarket_StableWorkerPool JobMarket_unresolvable_hostname_fix ODR_violation_mpqc_open PartialCharges_OrthogonalSummation PythonUI_with_named_parameters QtGui_reactivate_TimeChanged_changes Recreated_GuiChecks RotateToPrincipalAxisSystem_UndoRedo SaturateAtoms_findBestMatching StoppableMakroAction Subpackage_CodePatterns Subpackage_JobMarket Subpackage_LinearAlgebra Subpackage_levmar Subpackage_mpqc_open Subpackage_vmg ThirdParty_MPQC_rebuilt_buildsystem TrajectoryDependenant_MaxOrder TremoloParser_IncreasedPrecision TremoloParser_MultipleTimesteps Ubuntu_1604_changes stable
Last change on this file since 2199c2 was a498c1, checked in by Frederik Heber <heber@…>, 11 years ago

Extracted ResultContainer from ReceiveResultContainer.

  • Property mode set to 100644
File size: 2.7 KB
Line 
1/*
2 * SpecificFragmentController.hpp
3 *
4 * Created on: Aug 27, 2012
5 * Author: heber
6 */
7
8#ifndef SPECIFICFRAGMENTCONTROLLER_HPP_
9#define SPECIFICFRAGMENTCONTROLLER_HPP_
10
11
12// include config.h
13#ifdef HAVE_CONFIG_H
14#include <config.h>
15#endif
16
17#include "JobMarket/Controller/FragmentController.hpp"
18#include "JobMarket/types.hpp"
19#include "JobMarket/Results/FragmentResult.hpp"
20
21#include <boost/function.hpp>
22#include <map>
23#include <string>
24#include <vector>
25
26#include "Fragmentation/Automation/ResultContainer.hpp"
27
28/** This class extends FragmentController by some commodity functions used
29 * within FragmentationAutomationAction.
30 *
31 */
32class SpecificFragmentController : public FragmentController
33{
34public:
35 SpecificFragmentController(boost::asio::io_service &_io_service);
36 virtual ~SpecificFragmentController()
37 {}
38
39 typedef boost::function<void (const size_t,const size_t)> update_handler_t;
40
41 void setUpdateHandler(update_handler_t _handler)
42 {
43 handler = _handler;
44 }
45
46 void requestIds(const size_t numberjobs);
47 virtual void waitforResults(const size_t NoExpectedResults)=0;
48 void RunService(const std::string message);
49
50 /// getter and setter
51
52 void setHost(const std::string &_host) { host = _host; }
53 void setPort(const std::string &_port) { port = _port; }
54
55protected:
56
57 /** Container for the results received from the server.
58 *
59 * These are received bit by bit until all jobs are calculated.
60 * This struct takes of the waiting.
61 *
62 * We extend ResultContainer by functions to receive results from a
63 * JobMarket server.
64 *
65 */
66 template <typename T>
67 struct ReceiveResultContainer : public ResultContainer<T> {
68 /** cycle to wait for results
69 *
70 * \param NoExpectedResults number of expected results
71 * \param io_service service used for waiting
72 * \param callback ref to call controller functions
73 */
74 void waitforResults(
75 const size_t NoExpectedResults,
76 boost::asio::io_service &io_service,
77 SpecificFragmentController &callback);
78
79 /** Internal function to receive results if some are present.
80 *
81 * \param callback ref to call controller functions
82 * \return number of received results
83 */
84 size_t receiveResults(SpecificFragmentController &callback);
85 };
86
87protected:
88 //!> hostname of the server to control
89 std::string host;
90 //!> port of the server to control
91 std::string port;
92 //!> reference to io_service for internal purposes
93 boost::asio::io_service &io_service;
94 //!> update handler that is called in waitforResults()
95 update_handler_t handler;
96};
97
98#include "SpecificFragmentController_ReceiveResultContainer_impl.hpp"
99
100#endif /* SPECIFICFRAGMENTCONTROLLER_HPP_ */
Note: See TracBrowser for help on using the repository browser.