votca 2024.2-dev
Loading...
Searching...
No Matches
progressobserver.h
Go to the documentation of this file.
1/*
2 * Copyright 2009-2020 The VOTCA Development Team
3 * (http://www.votca.org)
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License")
6 *
7 * You may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *
18 */
21
22#pragma once
23#ifndef VOTCA_XTP_PROGRESSOBSERVER_H
24#define VOTCA_XTP_PROGRESSOBSERVER_H
25
26// Standard includes
27#include <vector>
28
29// Third party includes
30#include <boost/interprocess/sync/file_lock.hpp>
31#include <boost/program_options.hpp>
32
33// VOTCA includes
34#include <votca/tools/mutex.h>
36
37namespace votca {
38namespace xtp {
39
40class QMThread;
41
42template <typename JobContainer>
44
45 using Job = typename JobContainer::value_type;
46 using Result = typename Job::JobResult;
47
48 public:
49 void InitCmdLineOpts(const boost::program_options::variables_map &optsMap);
50 void InitFromProgFile(std::string progFile, QMThread &thread);
52 void ReportJobDone(Job &job, Result &res, QMThread &thread);
53
54 void SyncWithProgFile(QMThread &thread);
55 void LockProgFile(QMThread &thread);
56 void ReleaseProgFile(QMThread &thread);
57
58 std::string GenerateHost();
59 std::string GenerateTime();
60
61 private:
62 std::string lockFile_ = "";
63 std::string progFile_ = "";
65 JobContainer jobs_;
66
67 std::vector<Job *> jobsToProc_;
68 std::vector<Job *> jobsToSync_;
69
70 using iterator = typename JobContainer::iterator;
72 using iterator_vec = typename std::vector<Job *>::iterator;
75 std::unique_ptr<boost::interprocess::file_lock> flock_;
76
77 std::map<std::string, bool> restart_hosts_;
78 std::map<std::string, bool> restart_stats_;
79 bool restartMode_ = false;
81
82 bool moreJobsAvailable_ = false;
85};
86
87} // namespace xtp
88} // namespace votca
89#endif // VOTCA_XTP_PROGRESSOBSERVER_H
void LockProgFile(QMThread &thread)
typename JobContainer::value_type Job
std::vector< Job * > jobsToProc_
typename JobContainer::iterator iterator
void InitFromProgFile(std::string progFile, QMThread &thread)
void ReportJobDone(Job &job, Result &res, QMThread &thread)
ProgObserver::Job * RequestNextJob(QMThread &thread)
typename std::vector< Job * >::iterator iterator_vec
typename Job::JobResult Result
std::map< std::string, bool > restart_stats_
std::map< std::string, bool > restart_hosts_
void ReleaseProgFile(QMThread &thread)
void SyncWithProgFile(QMThread &thread)
void InitCmdLineOpts(const boost::program_options::variables_map &optsMap)
std::unique_ptr< boost::interprocess::file_lock > flock_
std::vector< Job * > jobsToSync_
base class for all analysis tools
Definition basebead.h:33
Eigen::Index Index
Definition types.h:26