Mantid
Loading...
Searching...
No Matches
ArrayLengthValidator.cpp
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
8#include <boost/python/class.hpp>
9#include <boost/python/copy_const_reference.hpp>
10#include <boost/python/return_value_policy.hpp>
11
14using namespace boost::python;
15
16namespace {
17
18#define EXPORT_LENGTHVALIDATOR(type, prefix) \
19 class_<ArrayLengthValidator<type>, bases<IValidator>, boost::noncopyable>(#prefix "ArrayLengthValidator") \
20 .def(init<int>((arg("self"), arg("length")), "Constructs a validator verifying that " \
21 "an array is of the exact length given")) \
22 .def(init<int, int>((arg("self"), arg("lenmin"), arg("lenmax")), \
23 "Constructs a validator verifying that the length " \
24 "of an array is within the range given")) \
25 .def("hasLength", &ArrayLengthValidator<type>::hasLength, arg("self"), \
26 "Returns true if a single length has been set") \
27 .def("hasMinLength", &ArrayLengthValidator<type>::hasMinLength, arg("self"), \
28 "Returns true if a minimum length has been set") \
29 .def("hasMaxLength", &ArrayLengthValidator<type>::hasMaxLength, arg("self"), \
30 "Returns true if a maximum length has been set") \
31 .def("getLength", &ArrayLengthValidator<type>::getLength, return_value_policy<copy_const_reference>(), \
32 arg("self"), "Returns the set fixed length") \
33 .def("getMinLength", &ArrayLengthValidator<type>::getMinLength, return_value_policy<copy_const_reference>(), \
34 arg("self"), "Returns the set minimum length") \
35 .def("getMaxLength", &ArrayLengthValidator<type>::getMaxLength, return_value_policy<copy_const_reference>(), \
36 arg("self"), "Returns the set maximum length") \
37 .def("setLength", &ArrayLengthValidator<type>::setLength, (arg("self"), arg("length")), \
38 "Set the accepted length of an array") \
39 .def("clearLength", &ArrayLengthValidator<type>::clearLength, arg("self"), "Clears accepted length of an array") \
40 .def("setLengthMin", &ArrayLengthValidator<type>::setLengthMin, (arg("self"), arg("minimum length")), \
41 "Set the accepted minimum length of an array") \
42 .def("setLengthMax", &ArrayLengthValidator<type>::setLengthMax, (arg("self"), arg("maximum length")), \
43 "Set the accepted maximum length of an array") \
44 .def("clearLengthMin", &ArrayLengthValidator<type>::clearLengthMin, arg("self"), \
45 "Set the accepted minimum length of an array") \
46 .def("clearLengthMax", &ArrayLengthValidator<type>::clearLengthMax, arg("self"), \
47 "Set the accepted maximum length of an array");
48} // namespace
49
51 EXPORT_LENGTHVALIDATOR(double, Float);
52 EXPORT_LENGTHVALIDATOR(long, Int);
53 EXPORT_LENGTHVALIDATOR(std::string, String);
54}
#define EXPORT_LENGTHVALIDATOR(type, prefix)
void export_ArrayLengthValidator()
ArrayLenghtValidator : Validate length of an array property.
IValidator is the basic interface for all validators for properties.
Definition: IValidator.h:43