Skip to content

Commit

Permalink
IRemoteJobManager is now in API not Kernel, re #11124
Browse files Browse the repository at this point in the history
  • Loading branch information
FedeMPouzols committed Mar 25, 2015
1 parent e6dbf39 commit 23472d9
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 25 deletions.
28 changes: 15 additions & 13 deletions Code/Mantid/Framework/API/inc/MantidAPI/RemoteJobManagerFactory.h
@@ -1,9 +1,9 @@
#ifndef MANTID_KERNEL_REMOTEJOBMANAGERFACTORY_H_
#define MANTID_KERNEL_REMOTEJOBMANAGERFACTORY_H_
#ifndef MANTID_API_REMOTEJOBMANAGERFACTORY_H_
#define MANTID_API_REMOTEJOBMANAGERFACTORY_H_

#include "MantidAPI/DllConfig.h"
#include "MantidAPI/IRemoteJobManager.h"
#include "MantidKernel/DynamicFactory.h"
#include "MantidKernel/IRemoteJobManager.h"
#include "MantidKernel/SingletonHolder.h"

namespace Mantid {
Expand All @@ -27,10 +27,13 @@ macro DECLARE_REMOTEJOBMANAGER (the same way you use DECLARE_ALGORITHM
for algorithms and remote algorithms).
As the algorithm, workspace and other factories in Mantid, this
factory is implemented as a singleton class. Typical usage:
factory is implemented as a singleton class. Typical usages:
Mantid::Kernel::IRemoteJob|Manager_sptr jobManager =
Mantid::API::IRemoteJobManager_sptr::Instance().create("Fermi");
Mantid::API::IRemoteJob|Manager_sptr jobManager =
Mantid::API::RemoteJobManagerFactory::Instance().create("Fermi");
Mantid::API::IRemoteJob|Manager_sptr jobManager =
Mantid::API::RemoteJobManagerFactory::Instance().create("SCARF@STFC");
Copyright © 2015 ISIS Rutherford Appleton Laboratory, NScD Oak Ridge
Expand All @@ -55,17 +58,16 @@ File change history is stored at: <https://github.com/mantidproject/mantid>.
Code Documentation is available at: <http://doxygen.mantidproject.org>
*/
class MANTID_API_DLL RemoteJobManagerFactoryImpl
: public Kernel::DynamicFactory<Mantid::Kernel::IRemoteJobManager> {
: public Kernel::DynamicFactory<IRemoteJobManager> {
public:
/// Create a remote job manager that will know how to use the
/// underlying mechanism that suits the compute resource passed
Mantid::Kernel::IRemoteJobManager_sptr
create(const std::string &computeResourceName) const;
IRemoteJobManager_sptr create(const std::string &computeResourceName) const;

/// alternative (lower level) create where the specific type of
/// manager and base URL are directly given
Mantid::Kernel::IRemoteJobManager_sptr
create(const std::string baseURL, const std::string jobManagerType) const;
IRemoteJobManager_sptr create(const std::string baseURL,
const std::string jobManagerType) const;

private:
/// So that the singleton can be created (cons/destructor are private)
Expand All @@ -82,7 +84,7 @@ class MANTID_API_DLL RemoteJobManagerFactoryImpl
virtual ~RemoteJobManagerFactoryImpl();

// Unhide the inherited create method but make it private
using Kernel::DynamicFactory<Mantid::Kernel::IRemoteJobManager>::create;
using Kernel::DynamicFactory<IRemoteJobManager>::create;
};

/// Forward declaration of a specialisation of SingletonHolder for
Expand Down Expand Up @@ -119,4 +121,4 @@ typedef MANTID_API_DLL Mantid::Kernel::SingletonHolder<
0)); \
}

#endif // MANTID_KERNEL_REMOTEJOBMANAGERFACTORY_H_
#endif // MANTID_API_REMOTEJOBMANAGERFACTORY_H_
10 changes: 5 additions & 5 deletions Code/Mantid/Framework/API/src/RemoteJobManagerFactory.cpp
Expand Up @@ -12,7 +12,7 @@ Kernel::Logger g_log("RemoteJobManagerFactory");

/// Private constructor, singleton class
RemoteJobManagerFactoryImpl::RemoteJobManagerFactoryImpl()
: Mantid::Kernel::DynamicFactory<Mantid::Kernel::IRemoteJobManager>() {
: Mantid::Kernel::DynamicFactory<IRemoteJobManager>() {
g_log.debug() << "RemoteJobManager factory created." << std::endl;
}

Expand All @@ -31,9 +31,9 @@ RemoteJobManagerFactoryImpl::~RemoteJobManagerFactoryImpl() {}
* given (compute resources are looked up in the facilities definition
* (XML) file for the current facility.
*/
Mantid::Kernel::IRemoteJobManager_sptr RemoteJobManagerFactoryImpl::create(
IRemoteJobManager_sptr RemoteJobManagerFactoryImpl::create(
const std::string &computeResourceName) const {
Mantid::Kernel::IRemoteJobManager_sptr jm;
IRemoteJobManager_sptr jm;

if (computeResourceName.empty())
return jm;
Expand Down Expand Up @@ -64,10 +64,10 @@ Mantid::Kernel::IRemoteJobManager_sptr RemoteJobManagerFactoryImpl::create(
* @throw std::invalid_argument If there is an issue with the URL or
* the type (for example the type is not recognized).
*/
Mantid::Kernel::IRemoteJobManager_sptr
Mantid::API::IRemoteJobManager_sptr
RemoteJobManagerFactoryImpl::create(const std::string baseURL,
const std::string jobManagerType) const {
Mantid::Kernel::IRemoteJobManager_sptr jm;
Mantid::API::IRemoteJobManager_sptr jm;

// use the inherited/generic create method
try {
Expand Down
14 changes: 7 additions & 7 deletions Code/Mantid/Framework/API/test/RemoteJobManagerFactoryTest.h
Expand Up @@ -6,13 +6,13 @@
#include "MantidKernel/FacilityInfo.h"

using namespace Mantid::API;
using namespace Mantid::Kernel;

// Just a minimal implementation of IRemoteJobManager, sufficient for the
// factory
class TestJM : public Mantid::Kernel::IRemoteJobManager {
class TestJM : public IRemoteJobManager {
public:
virtual void authenticate(std::string &username, std::string &password) {
virtual void authenticate(const std::string &username,
const std::string &password) {
UNUSED_ARG(username);
UNUSED_ARG(password);
}
Expand Down Expand Up @@ -106,7 +106,7 @@ class RemoteJobManagerFactoryTest : public CxxTest::TestSuite {

Mantid::Kernel::ConfigService::Instance().setFacility("SNS");
TS_ASSERT_THROWS(
Mantid::Kernel::IRemoteJobManager_sptr jobManager =
Mantid::API::IRemoteJobManager_sptr jobManager =
Mantid::API::RemoteJobManagerFactory::Instance().create(
"SCARF@STFC"),
Mantid::Kernel::Exception::NotFoundError);
Expand All @@ -127,13 +127,13 @@ class RemoteJobManagerFactoryTest : public CxxTest::TestSuite {
// done a DECLARE_REMOTEJOBMANAGER. Change this test when that is
// done (ticket #11126 etc.)
TS_ASSERT_THROWS(
Mantid::Kernel::IRemoteJobManager_sptr jobManager =
Mantid::API::IRemoteJobManager_sptr jobManager =
Mantid::API::RemoteJobManagerFactory::Instance().create("Fermi"),
Mantid::Kernel::Exception::NotFoundError);

Mantid::Kernel::ConfigService::Instance().setFacility("ISIS");
TS_ASSERT_THROWS(
Mantid::Kernel::IRemoteJobManager_sptr jobManager =
Mantid::API::IRemoteJobManager_sptr jobManager =
Mantid::API::RemoteJobManagerFactory::Instance().create(
"SCARF@STFC"),
Mantid::Kernel::Exception::NotFoundError);
Expand All @@ -143,7 +143,7 @@ class RemoteJobManagerFactoryTest : public CxxTest::TestSuite {
}

private:
Mantid::Kernel::IRemoteJobManager_sptr jm;
Mantid::API::IRemoteJobManager_sptr jm;
};

#endif /* REMOTEJOBMANAGERFACTORYTEST_H_ */

0 comments on commit 23472d9

Please sign in to comment.