Mantid
Loading...
Searching...
No Matches
Framework
TestHelpers
inc
MantidFrameworkTestHelpers
FacilityHelper.h
Go to the documentation of this file.
1
// Mantid Repository : https://github.com/mantidproject/mantid
2
//
3
// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI,
4
// NScD Oak Ridge National Laboratory, European Spallation Source,
5
// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6
// SPDX - License - Identifier: GPL - 3.0 +
7
/*********************************************************************************
8
* PLEASE READ THIS!!!!!!!
9
*
10
* This file MAY NOT be modified to use anything from a package other than
11
*Kernel.
12
*********************************************************************************/
13
#pragma once
14
15
#include "
MantidKernel/ConfigService.h
"
16
#include "
MantidKernel/FacilityInfo.h
"
17
#include <Poco/Path.h>
18
19
namespace
FacilityHelper
{
20
25
struct
ScopedFacilities
{
31
ScopedFacilities
(
const
std::string &filename,
const
std::string &defFacility) {
32
auto
&config = Mantid::Kernel::ConfigService::Instance();
33
defFacilityOnStart
= config.getFacility().name();
34
Poco::Path testFile = Poco::Path(config.getInstrumentDirectory()).resolve(filename);
35
// Load the test facilities file
36
config.updateFacilities(testFile.toString());
37
config.setFacility(defFacility);
38
}
39
40
~ScopedFacilities
() {
41
auto
&config = Mantid::Kernel::ConfigService::Instance();
42
// Restore the main facilities file
43
config.updateFacilities();
// no file loads the default
44
config.setFacility(
defFacilityOnStart
);
45
}
46
47
private
:
48
std::string
defFacilityOnStart
;
49
};
50
}
// namespace FacilityHelper
ConfigService.h
FacilityInfo.h
FacilityHelper
Definition
FacilityHelper.h:19
FacilityHelper::ScopedFacilities
Simple RAII struct to switch the facilities files to the when constructed and switch back to the prev...
Definition
FacilityHelper.h:25
FacilityHelper::ScopedFacilities::~ScopedFacilities
~ScopedFacilities()
Definition
FacilityHelper.h:40
FacilityHelper::ScopedFacilities::defFacilityOnStart
std::string defFacilityOnStart
Definition
FacilityHelper.h:48
FacilityHelper::ScopedFacilities::ScopedFacilities
ScopedFacilities(const std::string &filename, const std::string &defFacility)
Switch facilities file & default facility.
Definition
FacilityHelper.h:31
Generated by
1.9.8