13#include <boost/lexical_cast.hpp>
29 const std::string &
value)
61 std::shared_ptr<EnabledWhenProperty> &&conditionTwo,
68 :
IPropertySettings(), m_propertyDetails{other.m_propertyDetails}, m_comparisonDetails{other.m_comparisonDetails} {}
80 const auto &objectOne = comparison->conditionOne;
81 const auto &objectTwo = comparison->conditionTwo;
83 switch (comparison->logicOperator) {
85 return objectOne->isEnabled(algo) && objectTwo->isEnabled(algo);
88 return objectOne->isEnabled(algo) || objectTwo->isEnabled(algo);
91 return objectOne->isEnabled(algo) ^ objectTwo->isEnabled(algo);
94 throw std::runtime_error(
"Unknown logic operator in EnabledWhenProperty");
116 return prop->isDefault();
118 return !prop->isDefault();
125 auto iPropV = boost::lexical_cast<int>(propValue);
126 return (iPropV >= check);
130 std::string errString =
"The EnabledWhenProperty criterion set"
131 " for the following property ";
133 errString +=
" is unknown";
134 throw std::invalid_argument(errString);
149 throw std::runtime_error(
"Algorithm properties passed to EnabledWhenProperty was null");
158 throw std::runtime_error(
"Property " +
m_propertyDetails->otherPropName +
" was not found in EnabledWhenProperty");
159 return prop->
value();
176 throw std::runtime_error(
"Both PropertyDetails and ComparisonDetails were "
177 "null in EnabledWhenProperty");
double value
The value of the point.
#define UNUSED_ARG(x)
Function arguments are sometimes unused in certain implmentations but are required for documentation ...
EnabledWhenProperty()=default
Protected Constructor for derived classes to skip setting up the comparator in the base class as they...
std::string getPropertyValue(const IPropertyManager *algo) const
Checks the algorithm and property are both valid and attempts to get the value associated with the pr...
std::shared_ptr< ComparisonDetails< EnabledWhenProperty > > m_comparisonDetails
Holds an object containing details of multiple comparisons.
bool isEnabled(const IPropertyManager *algo) const override
Return true/false based on whether the other property satisfies the criterion.
virtual bool checkCriterion(const IPropertyManager *algo) const
Checks that the specified property matches the criteria given.
std::shared_ptr< PropertyDetails > m_propertyDetails
Holds the various details used within the comparison.
virtual bool checkComparison(const IPropertyManager *algo) const
Checks two EnabledWhenProperty objects match the logic operator specified and returns the result of b...
IPropertySettings * clone() const override
Make a copy of the present type of validator.
void modify_allowed_values(Property *const)
Stub function to satisfy the interface.
bool isVisible(const IPropertyManager *algo) const override
Return true always.
Exception for when an item is not found in a collection.
Interface to PropertyManager.
virtual Property * getPointerToProperty(const std::string &name) const =0
Get a pointer to property by name.
Interface for modifiers to Property's that specify if they should be enabled or visible in a GUI.
Base class for properties.
virtual std::string value() const =0
Returns the value of the property as a string.
ePropertyCriterion
Enum for use in EnabledWhenProperty.
eLogicOperator
Enum for use when combining two EnabledWhenPropertyItems.
Struct which holds details for comparison between two EnabledWhenPropertyObjects.
Struct which holds associated property details for comparison.