ADSValidator.h 1.8 KB
Newer Older
1
2
3
4
5
6
// Mantid Repository : https://github.com/mantidproject/mantid
//
// Copyright © 2016 ISIS Rutherford Appleton Laboratory UKRI,
//     NScD Oak Ridge National Laboratory, European Spallation Source
//     & Institut Laue - Langevin
// SPDX - License - Identifier: GPL - 3.0 +
7
#pragma once
8
9
10
11

//----------------------------------------------------------------------
// Includes
//----------------------------------------------------------------------
12
#include "MantidAPI/DllConfig.h"
LamarMoore's avatar
LamarMoore committed
13
#include "MantidKernel/TypedValidator.h"
14
15
16
17

namespace Mantid {
namespace API {

18
/** ADSValidator : a validator that requires the value of a property to be
19
20
    present in the ADS.  The  type must be std::string
*/
Nick Draper's avatar
Nick Draper committed
21
22
class MANTID_API_DLL ADSValidator
    : public Kernel::TypedValidator<std::vector<std::string>> {
23
24
25
public:
  /// Default constructor. Sets up an empty list of valid values.
  ADSValidator(const bool allowMultiSelection = true,
26
               const bool isOptional = false);
27
28

  /// Clone the validator
Nick Draper's avatar
Nick Draper committed
29
  Kernel::IValidator_sptr clone() const override;
30

Nick Draper's avatar
Nick Draper committed
31
  bool isMultipleSelectionAllowed() override;
32

Nick Draper's avatar
Nick Draper committed
33
  void setMultipleSelectionAllowed(const bool isMultiSelectionAllowed);
34

35
  bool isOptional() const;
36

Nick Draper's avatar
Nick Draper committed
37
38
  std::vector<std::string> allowedValues() const override;

39
  void setOptional(const bool setOptional);
40
41

protected:
42
43
  /** Checks if the string passed is in the ADS, or if all members are in the
   * ADS
44
   *  @param value :: The value to test
45
46
   *  @return "" if the value is on the list, or "The workspace is not in the
   * workspace list"
47
   */
Nick Draper's avatar
Nick Draper committed
48
49
  std::string
  checkValidity(const std::vector<std::string> &value) const override;
50
51
52
53
54
55
56
57
58
59
60

private:
  /// if the validator should allow multiple selection
  bool m_AllowMultiSelection;
  /// if the validator should an empty selection
  bool m_isOptional;
};

} // namespace API
} // namespace Mantid