Skip to content
Snippets Groups Projects
BatchJobRunner.h 3.18 KiB
Newer Older
// Mantid Repository : https://github.com/mantidproject/mantid
//
// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI,
//     NScD Oak Ridge National Laboratory, European Spallation Source
//     & Institut Laue - Langevin
// SPDX - License - Identifier: GPL - 3.0 +
#ifndef MANTID_CUSTOMINTERFACES_BATCHJOBRUNNER_H_
#define MANTID_CUSTOMINTERFACES_BATCHJOBRUNNER_H_

#include "Common/DllConfig.h"
#include "IBatchJobRunner.h"
#include "MantidAPI/IAlgorithm_fwd.h"
#include "MantidAPI/Workspace_fwd.h"
#include "MantidQtWidgets/Common/BatchAlgorithmRunner.h"
#include "Reduction/Batch.h"

namespace MantidQt {
namespace CustomInterfaces {
namespace ISISReflectometry {
 * The BatchJobRunner class sets up algorithms to run based on the reduction
 * configuration, and handles updating state when algorithms complete
class MANTIDQT_ISISREFLECTOMETRY_DLL BatchJobRunner : public IBatchJobRunner {
Gemma Guest's avatar
Gemma Guest committed
  explicit BatchJobRunner(Batch batch);
  bool isProcessing() const override;
  bool isAutoreducing() const override;
  int percentComplete() const override;
  void reductionResumed() override;
  void reductionPaused() override;
  void autoreductionResumed() override;
  void autoreductionPaused() override;
  void setReprocessFailedItems(bool reprocessFailed) override;
  Item const &
  algorithmStarted(MantidQt::API::IConfiguredAlgorithm_sptr algorithm) override;
  Item const &algorithmComplete(
      MantidQt::API::IConfiguredAlgorithm_sptr algorithm) override;
  Item const &algorithmError(MantidQt::API::IConfiguredAlgorithm_sptr algorithm,
                             std::string const &message) override;
  std::vector<std::string> algorithmOutputWorkspacesToSave(
      MantidQt::API::IConfiguredAlgorithm_sptr algorithm) const override;
  boost::optional<Item const &>
  notifyWorkspaceDeleted(std::string const &wsName) override;
  boost::optional<Item const &>
  notifyWorkspaceRenamed(std::string const &oldName,
                         std::string const &newName) override;
  void notifyAllWorkspacesDeleted() override;
  std::deque<MantidQt::API::IConfiguredAlgorithm_sptr> getAlgorithms() override;
  AlgorithmRuntimeProps rowProcessingProperties() const override;
protected:
  Batch m_batch;
  bool m_isProcessing;
  bool m_isAutoreducing;
  bool m_reprocessFailed;
  bool m_processAll;
  std::vector<MantidWidgets::Batch::RowLocation> m_rowLocationsToProcess;

Gemma Guest's avatar
Gemma Guest committed
  int itemsInSelection(Item::ItemCountFunction countFunction) const;
  std::vector<std::string> getWorkspacesToSave(Group const &group) const;
  std::vector<std::string> getWorkspacesToSave(Row const &row) const;
  template <typename T> bool isSelected(T const &item);
  bool hasSelectedRowsRequiringProcessing(Group const &group);
  std::deque<MantidQt::API::IConfiguredAlgorithm_sptr>
  algorithmForPostprocessingGroup(Group &group);
  std::deque<MantidQt::API::IConfiguredAlgorithm_sptr>
  algorithmsForProcessingRowsInGroup(Group &group, bool processAll);
  void addAlgorithmForProcessingRow(
      Row &row,
      std::deque<MantidQt::API::IConfiguredAlgorithm_sptr> &algorithms);
} // namespace ISISReflectometry
} // namespace CustomInterfaces
} // namespace MantidQt
#endif // MANTID_CUSTOMINTERFACES_BATCHJOBRUNNER_H_