Skip to content
Snippets Groups Projects
Commit d218ac0a authored by Jonathan Haigh's avatar Jonathan Haigh
Browse files

store python var name in workspace to pass between properties

parent ba48692c
Branches EWM6559_PDCalibration_masking_defect-main
No related tags found
No related merge requests found
......@@ -67,9 +67,11 @@ public:
void virtual setTitle(const std::string &);
void setComment(const std::string &);
void setPythonVariableName(const std::string &);
virtual const std::string getTitle() const;
const std::string &getComment() const;
const std::string &getName() const override;
const std::string &getPythonVariableName() const;
bool isDirty(const int n = 1) const;
virtual bool isGroup() const { return false; }
/// Get the footprint in memory in bytes.
......@@ -95,6 +97,8 @@ private:
/// The name associated with the object within the ADS (This is required for
/// workspace algebra
std::string m_name;
/// The name of the variable holding the workspace, if not stored in the ADS
std::string m_pythonVariableName;
/// The history of the workspace, algorithm and environment
std::unique_ptr<WorkspaceHistory> m_history;
......
......@@ -180,6 +180,9 @@ template <typename TYPE>
std::string WorkspaceProperty<TYPE>::setDataItem(const std::shared_ptr<Kernel::DataItem> &value) {
std::shared_ptr<TYPE> typed = std::dynamic_pointer_cast<TYPE>(value);
if (typed) {
if (typed->getName().empty() && this->direction() == Kernel::Direction::Output) {
typed->setPythonVariableName(m_workspaceName);
}
if (this->direction() == Kernel::Direction::Input) {
m_workspaceName = typed->getName();
}
......@@ -301,10 +304,16 @@ template <typename TYPE> const Kernel::PropertyHistory WorkspaceProperty<TYPE>::
bool isdefault = this->isDefault();
if ((wsName.empty() || this->hasTemporaryValue()) && this->operator()()) {
// give the property a temporary name in the history
std::ostringstream os;
os << "__TMP" << this->operator()().get();
wsName = os.str();
const auto pvName = Kernel::PropertyWithValue<std::shared_ptr<TYPE>>::m_value->getPythonVariableName();
if (!pvName.empty()) {
// TODO also set something to say this should be recreated as a variable.
wsName = pvName;
} else {
// give the property a temporary name in the history
std::ostringstream os;
os << "__TMP" << this->operator()().get();
wsName = os.str();
}
isdefault = false;
}
return Kernel::PropertyHistory(this->name(), wsName, this->type(), isdefault, this->direction());
......
......@@ -38,6 +38,8 @@ void Workspace::setComment(const std::string &c) { m_comment = c; }
*/
void Workspace::setName(const std::string &name) { m_name = name; }
void Workspace::setPythonVariableName(const std::string &name) { m_pythonVariableName = name; }
/** Get the workspace title
*
* @return The title
......@@ -56,6 +58,8 @@ const std::string &Workspace::getComment() const { return m_comment; }
*/
const std::string &Workspace::getName() const { return m_name; }
const std::string &Workspace::getPythonVariableName() const { return m_pythonVariableName; }
/**
* Check whether other algorithms have been applied to the
* workspace by checking the history length.
......
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