source: src/Jobs/JobMarket/FragmentJob.hpp@ 7f8c9a

Action_Thermostats Add_AtomRandomPerturbation Add_FitFragmentPartialChargesAction Add_RotateAroundBondAction Add_SelectAtomByNameAction Added_ParseSaveFragmentResults AddingActions_SaveParseParticleParameters Adding_Graph_to_ChangeBondActions Adding_MD_integration_tests Adding_ParticleName_to_Atom Adding_StructOpt_integration_tests AtomFragments Automaking_mpqc_open AutomationFragmentation_failures Candidate_v1.5.4 Candidate_v1.6.0 Candidate_v1.6.1 ChangeBugEmailaddress ChangingTestPorts ChemicalSpaceEvaluator CombiningParticlePotentialParsing 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_BoundInBox_CenterInBox_MoleculeActions Fix_ChargeSampling_PBC Fix_ChronosMutex Fix_FitPartialCharges Fix_FitPotential_needs_atomicnumbers Fix_ForceAnnealing Fix_IndependentFragmentGrids Fix_ParseParticles Fix_ParseParticles_split_forward_backward_Actions Fix_PopActions Fix_QtFragmentList_sorted_selection Fix_Restrictedkeyset_FragmentMolecule Fix_StatusMsg Fix_StepWorldTime_single_argument Fix_Verbose_Codepatterns Fix_fitting_potentials Fixes ForceAnnealing_goodresults ForceAnnealing_oldresults ForceAnnealing_tocheck ForceAnnealing_with_BondGraph ForceAnnealing_with_BondGraph_continued ForceAnnealing_with_BondGraph_continued_betteresults ForceAnnealing_with_BondGraph_contraction-expansion FragmentAction_writes_AtomFragments FragmentMolecule_checks_bonddegrees GeometryObjects Gui_Fixes Gui_displays_atomic_force_velocity ImplicitCharges IndependentFragmentGrids IndependentFragmentGrids_IndividualZeroInstances IndependentFragmentGrids_IntegrationTest IndependentFragmentGrids_Sole_NN_Calculation JobMarket_RobustOnKillsSegFaults JobMarket_StableWorkerPool JobMarket_unresolvable_hostname_fix MoreRobust_FragmentAutomation ODR_violation_mpqc_open PartialCharges_OrthogonalSummation PdbParser_setsAtomName PythonUI_with_named_parameters QtGui_reactivate_TimeChanged_changes Recreated_GuiChecks Rewrite_FitPartialCharges RotateToPrincipalAxisSystem_UndoRedo SaturateAtoms_findBestMatching SaturateAtoms_singleDegree StoppableMakroAction Subpackage_CodePatterns Subpackage_JobMarket Subpackage_LinearAlgebra Subpackage_levmar Subpackage_mpqc_open Subpackage_vmg Switchable_LogView ThirdParty_MPQC_rebuilt_buildsystem TrajectoryDependenant_MaxOrder TremoloParser_IncreasedPrecision TremoloParser_MultipleTimesteps TremoloParser_setsAtomName Ubuntu_1604_changes stable
Last change on this file since 7f8c9a was c3de51, checked in by Frederik Heber <heber@…>, 11 years ago

Added FragmentJob, ..Result, JobId, SystemCommandJob, and types from JobMarket.

  • taken over from version v1.1.4 with disclaimer adapted.
  • changed include paths to JobMarket -> Jobs/JobMarket.
  • these files are only used when no HAVE_JOBMARKET is defined.
  • SystemCommandJob had Info, causing extra Chronos entry.
  • Property mode set to 100644
File size: 3.0 KB
Line 
1/*
2 * FragmentJob.hpp
3 *
4 * Originally taken from my JobMarket project at 1.1.4.
5 *
6 * Created on: Oct 19, 2011
7 * Author: heber
8 */
9
10#ifndef FRAGMENTJOB_HPP_
11#define FRAGMENTJOB_HPP_
12
13// include config.h
14#ifdef HAVE_CONFIG_H
15#include <config.h>
16#endif
17
18#include <string>
19
20#include "boost/shared_ptr.hpp"
21#include "boost/serialization/access.hpp"
22#include "boost/serialization/shared_ptr.hpp"
23
24#ifdef HAVE_JOBMARKET
25#include "JobMarket/Results/FragmentResult.hpp"
26#include "JobMarket/JobId.hpp"
27#include "JobMarket/types.hpp"
28#else
29#include "Jobs//JobMarket/FragmentResult.hpp"
30#include "Jobs//JobMarket/JobId.hpp"
31#include "Jobs//JobMarket/types.hpp"
32#endif
33
34class FragmentController;
35class FragmentJobTest;
36class FragmentQueueTest;
37class FragmentWorker;
38
39/** FragmentJob contains all information for the Worker to start the job and
40 * deliver a FragmentResult.
41 *
42 * Important is that this class is fully serializable such that it can be
43 * transfered to a scheduler (server) and be deserialized by the Worker.
44 */
45class FragmentJob : public JobId
46{
47 //!> allow FragmentQueue unit test access
48 friend class FragmentQueueTest;
49 //!> allow own unit test access
50 friend class FragmentJobTest;
51 //!> allow FragmentController access to setJobId()
52 friend class FragmentController;
53
54public:
55 //!> typedef for priorities of a job
56 typedef size_t priority_t;
57
58private:
59 //!> Internal priority of the job
60 priority_t priority;
61
62public:
63 typedef boost::shared_ptr<FragmentJob> ptr;
64
65 FragmentJob(const JobId_t _JobId);
66 virtual ~FragmentJob();
67
68 virtual FragmentResult::ptr Work() = 0;
69
70 bool operator==(const FragmentJob &other) const;
71
72 bool operator!=(const FragmentJob &other) const {
73 return !(*this == other);
74 }
75
76 /** Less-than-operator required for priority queue.
77 *
78 * \param other other instance to compare to
79 * \return true - this instance is less than other (in priority)
80 */
81 bool operator<(const FragmentJob &other) const {
82 return priority < other.priority;
83 }
84
85 /** Setter for the job's priority.
86 *
87 * \param _priority priority to set
88 */
89 void setPriority(const priority_t _priority) {
90 priority = _priority;
91 }
92
93protected:
94 /** Passing JobId::setId() on to grant FragmentController' access.
95 *
96 * \param _id new id to set
97 */
98 void setId(const JobId_t _id) { JobId::setId(_id); }
99
100private:
101 /** private default cstor for serialization only
102 *
103 * Use normal cstor with JobId::IllegalJob if you want to instantiate
104 * a job without id.
105 */
106 FragmentJob();
107
108 friend class boost::serialization::access;
109 // serialization
110 template <typename Archive>
111 void serialize(Archive& ar, const unsigned int version)
112 {
113 ar & boost::serialization::base_object<JobId>(*this);
114 ar & priority;
115 }
116};
117
118/** Helper function for allow less on ptr's of FragmentJob.
119 *
120 * \param a first instance
121 * \param b second instance
122 * \return \see FragmentJob::operator<()
123 */
124inline
125bool operator<(const FragmentJob::ptr &a, const FragmentJob::ptr &b)
126{ return (*a) < (*b); }
127
128
129#endif /* FRAGMENTJOB_HPP_ */
Note: See TracBrowser for help on using the repository browser.