Mantid
Loading...
Searching...
No Matches
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
17#include <Poco/Path.h>
18
19namespace FacilityHelper {
20
31 ScopedFacilities(const std::string &filename, const std::string &defFacility) {
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
42 // Restore the main facilities file
43 config.updateFacilities(); // no file loads the default
44 config.setFacility(defFacilityOnStart);
45 }
46
47private:
48 std::string defFacilityOnStart;
49};
50} // namespace FacilityHelper
static T & Instance()
Return a reference to the Singleton instance, creating it if it does not already exist Creation is do...
Simple RAII struct to switch the facilities files to the when constructed and switch back to the prev...
ScopedFacilities(const std::string &filename, const std::string &defFacility)
Switch facilities file & default facility.