13#include <boost/lexical_cast.hpp>
30 const std::string &
value)
62 std::shared_ptr<EnabledWhenProperty> &&conditionTwo,
69 :
IPropertySettings(), m_propertyDetails{other.m_propertyDetails}, m_comparisonDetails{other.m_comparisonDetails} {}
81 const auto &objectOne = comparison->conditionOne;
82 const auto &objectTwo = comparison->conditionTwo;
84 switch (comparison->logicOperator) {
86 return objectOne->isEnabled(algo) && objectTwo->isEnabled(algo);
89 return objectOne->isEnabled(algo) || objectTwo->isEnabled(algo);
92 return objectOne->isEnabled(algo) ^ objectTwo->isEnabled(algo);
95 throw std::runtime_error(
"Unknown logic operator in EnabledWhenProperty");
119 return !prop->isDefault();
126 auto iPropV = boost::lexical_cast<int>(propValue);
127 return (iPropV >= check);
131 std::string errString =
"The EnabledWhenProperty criterion set"
132 " for the following property ";
134 errString +=
" is unknown";
135 throw std::invalid_argument(errString);
150 throw std::runtime_error(
"Algorithm properties passed to EnabledWhenProperty was null");
159 throw std::runtime_error(
"Property " +
m_propertyDetails->otherPropName +
" was not found in EnabledWhenProperty");
160 return prop->
value();
177 throw std::runtime_error(
"Both PropertyDetails and ComparisonDetails were "
178 "null in EnabledWhenProperty");
199 if (otherProp == thisProp)
200 throw std::runtime_error(
"EnabledWhenProperty: circular dependency detected");
201 return std::vector<std::string>{otherProp};
203 std::set<std::string> ps;
206 ps.insert(ps1.cbegin(), ps1.cend());
207 ps.insert(ps2.cbegin(), ps2.cend());
208 return std::vector<std::string>(ps.cbegin(), ps.cend());
210 return std::vector<std::string>{};
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::vector< std::string > dependsOn(const std::string &thisProp) const override
Other properties that this property depends on.
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.
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 bool isDefault() const =0
Overriden function that returns if property has the same value that it was initialised with,...
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.