BooleanBinaryOperationMD.cpp 2.68 KB
Newer Older
1
2
3
4
5
6
7

#include "MantidMDAlgorithms/BooleanBinaryOperationMD.h"
#include "MantidKernel/System.h"

using namespace Mantid::Kernel;
using namespace Mantid::API;

8
9
namespace Mantid {
namespace MDAlgorithms {
10

11
12
13
14
//----------------------------------------------------------------------------------------------
/// Algorithm's name for identification. @see Algorithm::name
const std::string BooleanBinaryOperationMD::name() const {
  return "BooleanBinaryOperationMD";
15
}
16

17
/// Algorithm's version for identification. @see Algorithm::version
18
int BooleanBinaryOperationMD::version() const { return 1; }
19

20
21
22
23
24
25
26
//----------------------------------------------------------------------------------------------
///
const std::string BooleanBinaryOperationMD::summary() const {
  std::string algo = this->name();
  algo = algo.substr(0, algo.size() - 2);
  return "Perform the " + algo + " boolean operation on two MDHistoWorkspaces";
}
27

28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
//----------------------------------------------------------------------------------------------
/// Is the operation commutative?
bool BooleanBinaryOperationMD::commutative() const { return true; }

//----------------------------------------------------------------------------------------------
/// Check the inputs and throw if the algorithm cannot be run
void BooleanBinaryOperationMD::checkInputs() {
  if (m_lhs_event || m_rhs_event)
    throw std::runtime_error("Cannot perform the " + this->name() +
                             " operation on a MDEventWorkspace.");
  if (!acceptScalar() && (m_lhs_scalar || m_rhs_scalar))
    throw std::runtime_error("Cannot perform the " + this->name() +
                             " operation on a WorkspaceSingleValue.");
  if (!this->commutative() && m_lhs_scalar)
    throw std::runtime_error("Cannot perform the " + this->name() +
                             " operation with a scalar on the left-hand side.");
}

//----------------------------------------------------------------------------------------------
/// Run the algorithm with an MDEventWorkspace as output
void BooleanBinaryOperationMD::execEvent() {
  throw std::runtime_error("Cannot perform the " + this->name() +
                           " operation on a MDEventWorkspace.");
}

//----------------------------------------------------------------------------------------------
/// Run the algorithm with a MDHisotWorkspace as output, scalar and operand
void BooleanBinaryOperationMD::execHistoScalar(
56
    Mantid::DataObjects::MDHistoWorkspace_sptr /*out*/,
57
58
59
60
    Mantid::DataObjects::WorkspaceSingleValue_const_sptr /*scalar*/) {
  throw std::runtime_error("Cannot perform the " + this->name() +
                           " operation on a WorkspaceSingleValue.");
}
61
62
63

} // namespace Mantid
} // namespace MDAlgorithms