12#include <json/value.h>
36 unsigned int direction)
37 :
BaseClass(name, defaultValue, direction), m_dataServiceKey(), m_defaultAsStr() {
39 throw std::invalid_argument(
"PropertyManagerProperty() requires a name");
51 return (mgr ? mgr->asString(
true) :
"");
79 (*this) = globalPropMgrs.retrieve(strValue);
86 auto value = (*this)();
88 value = std::make_shared<PropertyManager>();
91 std::string strValueToSet = strValue.empty() ?
"{}" : strValue;
92 std::ostringstream msg;
94 const std::unordered_set<std::string> ignored;
95 bool createMissing{
true};
96 value->resetProperties();
97 value->setProperties(strValueToSet, ignored, createMissing);
99 }
catch (std::invalid_argument &exc) {
100 msg <<
"Error setting value from string.\n"
101 "String is expected to contain either the name of a global "
102 "PropertyManager or a json-formatted object.\n"
105 }
catch (std::exception &exc) {
106 msg <<
"Error setting value from string.\n" << exc.what();
118 if (
value.type() == Json::objectValue) {
122 }
catch (std::exception &exc) {
123 return std::string(
"Attempt to set Json value to property failed: ") + exc.what();
126 return std::string(
"Attempt to set incorrect Json type to "
127 "PropertyManager. Expected objectValue, found " +
136MANTID_KERNEL_DLL
PropertyManager_sptr IPropertyManager::getValue<PropertyManager_sptr>(
const std::string &name)
const {
141 throw std::runtime_error(std::string(
"Attempt to assign property ") + name +
142 " to incorrect type. Expected shared_ptr<PropertyManager>.");
148IPropertyManager::getValue<PropertyManager_const_sptr>(
const std::string &name)
const {
151 return prop->operator()();
153 std::string message =
154 "Attempt to assign property " + name +
" to incorrect type. Expected const shared_ptr<PropertyManager>.";
155 throw std::runtime_error(message);
double value
The value of the point.
Exception for when an item is not found in a collection.
virtual Property * getPointerToProperty(const std::string &name) const =0
Get a pointer to property by name.
std::string m_dataServiceKey
Json::Value valueAsJson() const override
Create a Json::Value objectValue from the PropertyManager.
std::string m_defaultAsStr
std::string setValueFromJson(const Json::Value &value) override
Sets the value of the property from a Json object.
std::string setValue(const std::string &strValue) override
Overwrite the current value.
PropertyManagerProperty(const std::string &name, unsigned int direction=Direction::Input)
Constructor with a default empty pointer.
std::string getDefault() const override
PropertyManager_sptr ValueType
std::string value() const override
const std::string & name() const
Get the property's name.
static T & Instance()
Return a reference to the Singleton instance, creating it if it does not already exist Creation is do...
std::shared_ptr< const PropertyManager > PropertyManager_const_sptr
shared pointer to Mantid::Kernel::PropertyManager(const version)
MANTID_KERNEL_DLL PropertyManager_sptr createPropertyManager(const Json::Value &keyValues)
Attempt to create a PropertyManager from the Json::Value.
std::shared_ptr< PropertyManager > PropertyManager_sptr
Typedef for a shared pointer to a PropertyManager.
std::string to_string(const wide_integer< Bits, Signed > &n)