Commit 689f533f authored by Roman Tolchenov's avatar Roman Tolchenov
Browse files

Re #19909. Restore asString's signature.

parent 726c813b
......@@ -66,9 +66,6 @@ public:
/// Returns the function's name
std::string name() const override { return "CompositeFunction"; }
/// Writes itself into a string
std::string
asString(const std::string &parentLocalAttributesStr = "") const override;
/// Sets the workspace for each member function
void setWorkspace(boost::shared_ptr<const Workspace> ws) override;
/// Set matrix workspace
......@@ -221,6 +218,9 @@ protected:
void setParameterStatus(size_t i, ParameterStatus status) override;
/// Get status of parameter
ParameterStatus getParameterStatus(size_t i) const override;
/// Writes itself into a string
std::string
writeToString(const std::string &parentLocalAttributesStr = "") const override;
size_t paramOffset(size_t i) const { return m_paramOffsets[i]; }
......
......@@ -324,8 +324,7 @@ public:
/// Returns the function's name
virtual std::string name() const = 0;
/// Writes itself into a string
virtual std::string
asString(const std::string &localAttributesStr = "") const;
std::string asString() const;
/// Virtual copy constructor
virtual boost::shared_ptr<IFunction> clone() const;
/// Set the workspace.
......@@ -590,6 +589,9 @@ protected:
const API::IFunction::Attribute &value) const;
/// Add a new tie. Derived classes must provide storage for ties
virtual void addTie(std::unique_ptr<ParameterTie> tie);
/// Writes itself into a string
virtual std::string
writeToString(const std::string &parentLocalAttributesStr = "") const;
friend class ParameterTie;
friend class CompositeFunction;
......
......@@ -45,9 +45,6 @@ public:
/// Returns the function's name
std::string name() const override { return "ImmutableCompositeFunction"; }
/// Writes itself into a string
std::string
asString(const std::string &parentLocalAttributesStr = "") const override;
/// Set i-th parameter
void setParameter(size_t i, const double &value,
bool explicitlySet = true) override {
......@@ -86,6 +83,9 @@ protected:
void addDefaultTies(const std::string &ties);
/// Add default constraints
void addDefaultConstraints(const std::string &constraints);
/// Writes itself into a string
std::string
writeToString(const std::string &parentLocalAttributesStr = "") const override;
private:
/// Keep paramater aliases
......
......@@ -36,9 +36,9 @@ CompositeFunction::CompositeFunction()
void CompositeFunction::init() {}
/**
* Writes itself into a string. Functions derived from CompositeFunction must
* override this method with something like this:
* std::string NewFunction::asString()const
* Writes itself into a string. Functions derived from CompositeFunction may
* need to override this method with something like this:
* std::string NewFunction::writeToString()const
* {
* ostr << "composite=" << this->name() << ';';
* // write NewFunction's own attributes and parameters
......@@ -52,7 +52,7 @@ void CompositeFunction::init() {}
* @return the string representation of the composite function
*/
std::string
CompositeFunction::asString(const std::string &parentLocalAttributesStr) const {
CompositeFunction::writeToString(const std::string &parentLocalAttributesStr) const {
std::ostringstream ostr;
// if empty just return function name
......@@ -89,7 +89,7 @@ CompositeFunction::asString(const std::string &parentLocalAttributesStr) const {
<< localAttValue;
}
}
ostr << fun->asString(localAttributesStr.str());
ostr << fun->writeToString(localAttributesStr.str());
if (isComp)
ostr << ')';
if (i < nFunctions() - 1) {
......
......@@ -395,13 +395,23 @@ std::string IFunction::writeConstraints() const {
}
/**
* Writes a string that can be used in Fit.IFunction to create a copy of this
* Writes a string that can be used in FunctionFunctory to create a copy of this
* IFunction
* @param localAttributesStr :: A preformatted string with local attributes.
* Can be passed in by a CompositeFunction (eg MultiDomainFunction).
* @return string representation of the function
*/
std::string IFunction::asString(const std::string &localAttributesStr) const {
std::string IFunction::asString() const {
return writeToString();
}
/**
* Writes this function into a string.
* @param parentLocalAttributesStr :: A preformatted string with local
* attributes of a parent composite function. Can be passed in by a
* CompositeFunction (eg MultiDomainFunction).
* @return string representation of the function
*/
std::string
IFunction::writeToString(const std::string &parentLocalAttributesStr) const {
std::ostringstream ostr;
ostr << "name=" << this->name();
// print the attributes
......@@ -442,7 +452,7 @@ std::string IFunction::asString(const std::string &localAttributesStr) const {
<< ")";
}
// "local" attributes of a parent composite function
ostr << localAttributesStr;
ostr << parentLocalAttributesStr;
return ostr.str();
}
......
......@@ -16,9 +16,9 @@ using std::size_t;
* Overridden method creates an initialization string which makes it look like a
* siple function.
*/
std::string ImmutableCompositeFunction::asString(
std::string ImmutableCompositeFunction::writeToString(
const std::string &parentLocalAttributesStr) const {
return IFunction::asString(parentLocalAttributesStr);
return IFunction::writeToString(parentLocalAttributesStr);
}
/**
......
......@@ -36,10 +36,10 @@ public:
std::string name() const override { return "CrystalFieldSpectrum"; }
const std::string category() const override { return "General"; }
void buildTargetFunction() const override;
std::string
asString(const std::string &parentLocalAttributesStr = "") const override;
protected:
std::string
writeToString(const std::string &parentLocalAttributesStr = "") const override;
void updateTargetFunction() const override;
private:
......
......@@ -97,7 +97,7 @@ void CrystalFieldSpectrum::updateTargetFunction() const {
}
/// Custom string conversion method
std::string CrystalFieldSpectrum::asString(
std::string CrystalFieldSpectrum::writeToString(
const std::string &parentLocalAttributesStr) const {
std::ostringstream ostr;
ostr << "name=" << this->name();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment