Skip to content

Commit

Permalink
Re #5822. Fixes to the attribute methods
Browse files Browse the repository at this point in the history
  • Loading branch information
mantid-roman committed Sep 7, 2012
1 parent ac45146 commit b85b736
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class DLLExport TabulatedFunction : public API::ParamFunction, public API::IFunc
/// Set a value to attribute attName
void setAttribute(const std::string& attName,const IFunction::Attribute& value);
/// Check if attribute attName exists
bool hasAttribute(const std::string& attName)const{return attName == "FileName";}
bool hasAttribute(const std::string& attName)const;

private:

Expand Down
15 changes: 14 additions & 1 deletion Code/Mantid/Framework/CurveFitting/src/TabulatedFunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,9 @@ void TabulatedFunction::clear()
/// Returns a list of attribute names
std::vector<std::string> TabulatedFunction::getAttributeNames()const
{
std::vector<std::string> res(1,"FileName");
std::vector<std::string> res(2);
res[0] = "FileName";
res[1] = "Workspace";
return res;
}

Expand Down Expand Up @@ -175,6 +177,17 @@ IFunction::Attribute TabulatedFunction::getAttribute(const std::string& attName)
return IFunction::getAttribute( attName );
}

/**
* Check if attribute attName exists
* @param attName :: A name to check.
*/
bool TabulatedFunction::hasAttribute(const std::string& attName)const
{
std::string aName( attName );
std::transform(aName.begin(),aName.end(),aName.begin(),toupper);
return aName == "FILENAME" || aName == "WORKSPACE";
}

/**
* Decide whether to load the file as an ASCII file or as a Nexus file.
* @param fname :: The file name
Expand Down
11 changes: 11 additions & 0 deletions Code/Mantid/Framework/CurveFitting/test/TabulatedFunctionTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,17 @@ class TabulatedFunctionTest : public CxxTest::TestSuite
AnalysisDataService::Instance().clear();
}

void test_Attributes()
{
TabulatedFunction fun;
auto names = fun.getAttributeNames();
TS_ASSERT_EQUALS( names.size(), 2 );
TS_ASSERT_EQUALS( names[0], "FileName" );
TS_ASSERT_EQUALS( names[1], "Workspace" );
TS_ASSERT( fun.hasAttribute("FileName") );
TS_ASSERT( fun.hasAttribute("Workspace") );
}

private:
const std::string m_asciiFileName;
const std::string m_nexusFileName;
Expand Down

0 comments on commit b85b736

Please sign in to comment.