11#include <json/value.h>
29template <
class E, std::vector<std::
string> const *const names>
37template <
class E, std::vector<std::
string> const *const names>
44template <
class E, std::vector<std::
string> const *const names>
57template <
class E, std::vector<std::
string> const *const names>
73template <
class E, std::vector<std::
string> const *const names>
75 return static_cast<std::string
>(
m_value);
81template <
class E, std::vector<std::
string> const *const names>
83 bool const collapseLists)
const {
91template <
class E, std::vector<std::
string> const *const names>
101template <
class E, std::vector<std::
string> const *const names>
105 return (
static_cast<E
>(this->
m_value) ==
static_cast<E
>(
rhs.m_value));
113template <
class E, std::vector<std::
string> const *const names>
115 return !(*
this ==
rhs);
127template <
class E, std::vector<std::
string> const *const names>
129 return static_cast<std::string
>(m_initialValue);
136template <
class E, std::vector<std::
string> const *const names>
144template <
class E, std::vector<std::
string> const *const names>
149 return "EnumeratedStringProperty was not set with valid EnumeratedString.\n";
158template <
class E, std::vector<std::
string> const *const names>
160 return m_initialValue ==
m_value;
168template <
class E, std::vector<std::
string> const *const names>
182template <
class E, std::vector<std::
string> const *const names>
193template <
class E, std::vector<std::
string> const *const names>
197 }
catch (std::runtime_error &exc) {
198 const std::string msg = exc.what();
200 return "value \"" +
value +
"\" not in allowed list";
212template <
class E, std::vector<std::
string> const *const names>
224template <
class E, std::vector<std::
string> const *const names>
226 if (
value.type() != Json::stringValue) {
228 *
this = decode<E>(
value);
229 }
catch (std::invalid_argument &exc) {
234 return setValue(
value.asString());
244template <
class E, std::vector<std::
string> const *const names>
259template <
class E, std::vector<std::
string> const *const names>
272template <
class E, std::vector<std::
string> const *const names>
285template <
class E, std::vector<std::
string> const *const names>
301template <
class E, std::vector<std::
string> const *const names>
303 std::ostringstream oss;
304 oss <<
"Cannot add EnumeratedStringProperty " << std::hex << std::showbase << reinterpret_cast<uintptr_t>(&
right)
305 <<
", addition not implemented." << std::endl;
306 throw std::invalid_argument(oss.str());
309template <
class E, std::vector<std::
string> const *const names>
314 throw std::invalid_argument(
"PropertyWithValue::saveProperty - Cannot save '" + this->
name() +
"', property type " +
329template <
class E, std::vector<std::
string> const *const names>
336 return setValue(
right.value());
347template <
class E, std::vector<std::
string> const *const names>
353 }
catch (std::runtime_error &exc) {
366template <
class E, std::vector<std::
string> const *const names>
369 return "Attempt to assign object of type DataItem to property (" +
name() +
") of incorrect type";
const std::string & m_value
const std::vector< double > & rhs
double value
The value of the point.
A concrete property based on user options of a finite list of strings.
std::string isValid() const override
If the value has been set, then it is valid.
std::string setDataItem(const std::shared_ptr< DataItem > &data) override
Set a property value via a DataItem.
void saveProperty(Nexus::File *file) override
int size() const override
Get the size of the property.
std::string setTypedValue(U const &value, std::true_type const &)
Helper function for setValue(DataItem_sptr).
std::string getDefault() const override
Get the value the property was initialised with -its default value.
std::string valueAsPrettyStr(size_t const maxLength=0, bool const collapseLists=true) const override
Get the value of the property as a more prettier string.
Json::Value valueAsJson() const override
Attempt to construct a Json::Value object from the plain value.
EnumeratedStringProperty * clone() const override
Virtual copy constructor.
ENUMSTRING operator()() const
Allows you to get the value of the property simply by typing its name.
bool operator==(EnumeratedStringProperty const &rhs) const
Deep comparison.
EnumeratedStringProperty & operator=(EnumeratedStringProperty const &right)
Assignment operator.
EnumeratedStringProperty(std::string const &name, ENUMSTRING const &defaultValue=static_cast< E >(0), Direction::Type const direction=Direction::Input)
Constructor.
ENUMSTRING m_value
The value of the property.
std::vector< std::string > allowedValues() const override
Returns the set of valid values for this property, if such a set exists.
std::string value() const override
Get the value of the property as a string.
bool isDefault() const override
Indicates if the property's value is the same as it was when it was set N.B.
std::string setValueFromProperty(Property const &right) override
Set the value of the property via a reference to another property.
bool operator!=(EnumeratedStringProperty const &rhs) const
Deep comparison (not equal).
std::string setValue(E const value)
Set the value of the property from a string representation.
EnumeratedStringProperty & operator+=(Property const *right) override
Add the value of another property.
std::string setValueFromJson(const Json::Value &value) override
Set the value of the property from a Json representation.
Base class for properties.
const std::string & name() const
Get the property's name.
MANTID_KERNEL_DLL::Json::Value encodeAsJson(const OptionalBool &)
Encode an OptionalBool as a Json::Value.
std::string toPrettyString(const T &value, size_t maxLength=0, bool collapseLists=true)
Convert values to pretty strings.
Type
Enum giving the possible directions.