Skip to content
Snippets Groups Projects
Commit c5484a88 authored by Edward Brown's avatar Edward Brown
Browse files

Re #221244: Changed other Property class operator= return types.

parent 210c48da
No related branches found
No related tags found
No related merge requests found
...@@ -95,8 +95,7 @@ public: ...@@ -95,8 +95,7 @@ public:
WorkspaceProperty &operator=(const WorkspaceProperty &right); WorkspaceProperty &operator=(const WorkspaceProperty &right);
boost::shared_ptr<TYPE> & WorkspaceProperty &operator=(const boost::shared_ptr<TYPE> &value) override;
operator=(const boost::shared_ptr<TYPE> &value) override;
WorkspaceProperty &operator+=(Kernel::Property const *) override; WorkspaceProperty &operator+=(Kernel::Property const *) override;
......
...@@ -107,13 +107,14 @@ operator=(const WorkspaceProperty &right) { ...@@ -107,13 +107,14 @@ operator=(const WorkspaceProperty &right) {
* @return assigned PropertyWithValue * @return assigned PropertyWithValue
*/ */
template <typename TYPE> template <typename TYPE>
boost::shared_ptr<TYPE> &WorkspaceProperty<TYPE>:: WorkspaceProperty<TYPE> &WorkspaceProperty<TYPE>::
operator=(const boost::shared_ptr<TYPE> &value) { operator=(const boost::shared_ptr<TYPE> &value) {
std::string wsName = value->getName(); std::string wsName = value->getName();
if (this->direction() == Kernel::Direction::Input && !wsName.empty()) { if (this->direction() == Kernel::Direction::Input && !wsName.empty()) {
m_workspaceName = wsName; m_workspaceName = wsName;
} }
return Kernel::PropertyWithValue<boost::shared_ptr<TYPE>>::operator=(value); Kernel::PropertyWithValue<boost::shared_ptr<TYPE>>::operator=(value);
return *this;
} }
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
......
...@@ -259,7 +259,7 @@ operator+=(Property const *right) { ...@@ -259,7 +259,7 @@ operator+=(Property const *right) {
* @return the reference to itself * @return the reference to itself
*/ */
template <typename TYPE> template <typename TYPE>
TYPE &PropertyWithValue<TYPE>::operator=(const TYPE &value) { PropertyWithValue<TYPE> &PropertyWithValue<TYPE>::operator=(const TYPE &value) {
TYPE oldValue = m_value; TYPE oldValue = m_value;
if (std::is_same<TYPE, std::string>::value) { if (std::is_same<TYPE, std::string>::value) {
std::string valueCopy = toString(value); std::string valueCopy = toString(value);
...@@ -272,10 +272,10 @@ TYPE &PropertyWithValue<TYPE>::operator=(const TYPE &value) { ...@@ -272,10 +272,10 @@ TYPE &PropertyWithValue<TYPE>::operator=(const TYPE &value) {
} }
std::string problem = this->isValid(); std::string problem = this->isValid();
if (problem.empty()) { if (problem.empty()) {
return m_value; return *this;
} else if (problem == "_alias") { } else if (problem == "_alias") {
m_value = getValueForAlias(value); m_value = getValueForAlias(value);
return m_value; return *this;
} else { } else {
m_value = oldValue; m_value = oldValue;
throw std::invalid_argument(problem); throw std::invalid_argument(problem);
......
...@@ -242,21 +242,24 @@ public: ...@@ -242,21 +242,24 @@ public:
ArrayProperty<int> i("i"); ArrayProperty<int> i("i");
TS_ASSERT(i.isDefault()) TS_ASSERT(i.isDefault())
std::vector<int> ii(3, 4); std::vector<int> ii(3, 4);
TS_ASSERT_EQUALS(i = ii, ii) i = ii;
TS_ASSERT_EQUALS(i.operator()(), ii);
TS_ASSERT_EQUALS(i.operator()()[1], 4) TS_ASSERT_EQUALS(i.operator()()[1], 4)
TS_ASSERT(!i.isDefault()) TS_ASSERT(!i.isDefault())
ArrayProperty<double> d("d"); ArrayProperty<double> d("d");
TS_ASSERT(d.isDefault()) TS_ASSERT(d.isDefault())
std::vector<double> dd(5, 9.99); std::vector<double> dd(5, 9.99);
TS_ASSERT_EQUALS(d = dd, dd) d = dd;
TS_ASSERT_EQUALS(d.operator()(), dd);
TS_ASSERT_EQUALS(d.operator()()[3], 9.99) TS_ASSERT_EQUALS(d.operator()()[3], 9.99)
TS_ASSERT(!d.isDefault()) TS_ASSERT(!d.isDefault())
ArrayProperty<std::string> s("s"); ArrayProperty<std::string> s("s");
TS_ASSERT(s.isDefault()) TS_ASSERT(s.isDefault())
std::vector<std::string> ss(2, "zzz"); std::vector<std::string> ss(2, "zzz");
TS_ASSERT_EQUALS(s = ss, ss) s = ss;
TS_ASSERT_EQUALS(s.operator()(), ss)
TS_ASSERT_EQUALS(s.operator()()[0], "zzz") TS_ASSERT_EQUALS(s.operator()()[0], "zzz")
TS_ASSERT(!s.isDefault()) TS_ASSERT(!s.isDefault())
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment