Skip to content

Commit

Permalink
Tidy algorithms. Refs #8445.
Browse files Browse the repository at this point in the history
- Used auto when possible for cleaner code.
- As most of the algorithms only make use of the catalog to invoke a specific method I now do this directly rather than in two steps.
  • Loading branch information
jawrainey committed Nov 14, 2013
1 parent d87549d commit 870e791
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 31 deletions.
11 changes: 3 additions & 8 deletions Code/Mantid/Framework/ICat/src/CatalogGetDataFiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,10 @@ namespace Mantid
//execute the algorithm
void CatalogGetDataFiles::exec()
{
API::ICatalog_sptr catalog = CatalogAlgorithmHelper().createCatalog();

int64_t investigationId = getProperty("InvestigationId");

API::ITableWorkspace_sptr ws_sptr = API::WorkspaceFactory::Instance().createTable("TableWorkspace");

catalog->getDataFiles(investigationId,ws_sptr);

setProperty("OutputWorkspace",ws_sptr);
auto workspace = API::WorkspaceFactory::Instance().createTable("TableWorkspace");
CatalogAlgorithmHelper().createCatalog()->getDataFiles(investigationId,workspace);
setProperty("OutputWorkspace",workspace);
}

}
Expand Down
7 changes: 3 additions & 4 deletions Code/Mantid/Framework/ICat/src/CatalogGetDataSets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,10 @@ namespace Mantid
/// exec methods
void CatalogGetDataSets::exec()
{
API::ICatalog_sptr catalog = CatalogAlgorithmHelper().createCatalog();
API::ITableWorkspace_sptr ws_sptr = API::WorkspaceFactory::Instance().createTable("TableWorkspace");
auto workspace = API::WorkspaceFactory::Instance().createTable("TableWorkspace");
int64_t investigationId = getProperty("InvestigationId");
catalog->getDataSets(investigationId,ws_sptr);
setProperty("OutputWorkspace",ws_sptr);
CatalogAlgorithmHelper().createCatalog()->getDataSets(investigationId,workspace);
setProperty("OutputWorkspace",workspace);
}

}
Expand Down
3 changes: 1 addition & 2 deletions Code/Mantid/Framework/ICat/src/CatalogListInstruments.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,8 @@ namespace Mantid
/// exec method
void CatalogListInstruments::exec()
{
API::ICatalog_sptr catalog = CatalogAlgorithmHelper().createCatalog();
std::vector<std::string> intruments;
catalog->listInstruments(intruments);
CatalogAlgorithmHelper().createCatalog()->listInstruments(intruments);
setProperty("InstrumentList",intruments);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,8 @@ namespace Mantid
/// exec method
void CatalogListInvestigationTypes::exec()
{
API::ICatalog_sptr catalog = CatalogAlgorithmHelper().createCatalog();
std::vector<std::string> investTypes;
catalog->listInvestigationTypes(investTypes);
CatalogAlgorithmHelper().createCatalog()->listInvestigationTypes(investTypes);
setProperty("InvestigationTypes",investTypes);
}

Expand Down
7 changes: 1 addition & 6 deletions Code/Mantid/Framework/ICat/src/CatalogLogin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,11 @@ namespace Mantid
/// execute the algorithm
void CatalogLogin::exec()
{
// Create and use the catalog the user has specified in Facilities.xml
API::ICatalog_sptr catalog = CatalogAlgorithmHelper().createCatalog();

std::string username = getProperty("Username");
std::string password = getProperty("Password");

g_log.notice() << "Verifying user credentials..." << std::endl;
progress(0.5, "Verifying user credentials...");

catalog->login(username,password,"");
CatalogAlgorithmHelper().createCatalog()->login(username, password, "");
}

}
Expand Down
3 changes: 1 addition & 2 deletions Code/Mantid/Framework/ICat/src/CatalogLogout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ namespace Mantid
/// execute the algorithm
void CatalogLogout::exec()
{
API::ICatalog_sptr catalog = CatalogAlgorithmHelper().createCatalog();
catalog->logout();
CatalogAlgorithmHelper().createCatalog()->logout();
}
}
}
5 changes: 2 additions & 3 deletions Code/Mantid/Framework/ICat/src/CatalogMyDataSearch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,8 @@ namespace Mantid
void CatalogMyDataSearch::exec()
{
// Create and use the catalog the user has specified in Facilities.xml
ICatalog_sptr catalog = CatalogAlgorithmHelper().createCatalog();
API::ITableWorkspace_sptr outputws = WorkspaceFactory::Instance().createTable("TableWorkspace");
catalog->myData(outputws);
auto outputws = WorkspaceFactory::Instance().createTable("TableWorkspace");
CatalogAlgorithmHelper().createCatalog()->myData(outputws);
setProperty("OutputWorkspace",outputws);
}
}
Expand Down
6 changes: 2 additions & 4 deletions Code/Mantid/Framework/ICat/src/CatalogSearch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,14 @@ namespace Mantid
/// Execution method.
void CatalogSearch::exec()
{
// Create and use the catalog the user has specified in Facilities.xml
ICatalog_sptr catalog = CatalogAlgorithmHelper().createCatalog();
// Obtains the inputs from the search interface.
CatalogSearchParam params;
// Get the user input search terms to search for.
getInputProperties(params);
// Create output workspace.
ITableWorkspace_sptr workspace = WorkspaceFactory::Instance().createTable("TableWorkspace");
auto workspace = WorkspaceFactory::Instance().createTable("TableWorkspace");
// Search for investigations in the archives.
catalog->search(params,workspace);
CatalogAlgorithmHelper().createCatalog()->search(params,workspace);
// Search for investigations with user specific search inputs.
setProperty("OutputWorkspace",workspace);
}
Expand Down

0 comments on commit 870e791

Please sign in to comment.