Skip to content

Commit

Permalink
Refs #11101 Initial commit with some of the class structure.
Browse files Browse the repository at this point in the history
  • Loading branch information
ianbush committed Feb 17, 2015
1 parent 1b8b39e commit b94b3f4
Show file tree
Hide file tree
Showing 4 changed files with 137 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Code/Mantid/Framework/API/CMakeLists.txt
Expand Up @@ -31,6 +31,7 @@ set ( SRC_FILES
src/ExperimentInfo.cpp
src/Expression.cpp
src/FermiChopperModel.cpp
src/FileBackedExperimentInfo.cpp
src/FileFinder.cpp
src/FileLoaderRegistry.cpp
src/FileProperty.cpp
Expand Down Expand Up @@ -170,6 +171,7 @@ set ( INC_FILES
inc/MantidAPI/ExperimentInfo.h
inc/MantidAPI/Expression.h
inc/MantidAPI/FermiChopperModel.h
inc/MantidAPI/FileBackedExperimentInfo.h
inc/MantidAPI/FileFinder.h
inc/MantidAPI/FileLoaderRegistry.h
inc/MantidAPI/FileProperty.h
Expand Down Expand Up @@ -309,6 +311,7 @@ set ( TEST_FILES
ExperimentInfoTest.h
ExpressionTest.h
FermiChopperModelTest.h
FileBackedExperimentInfoTest.h
FileFinderTest.h
FilePropertyTest.h
FrameworkManagerTest.h
Expand Down
58 changes: 58 additions & 0 deletions Code/Mantid/Framework/API/inc/MantidAPI/FileBackedExperimentInfo.h
@@ -0,0 +1,58 @@
#ifndef MANTID_API_FILEBACKEDEXPERIMENTINFO_H_
#define MANTID_API_FILEBACKEDEXPERIMENTINFO_H_

#include "MantidKernel/System.h"
#include "MantidAPI/ExperimentInfo.h"

#if defined(__GLIBCXX__) && __GLIBCXX__ >= 20100121 // libstdc++-4.4.3
typedef std::unique_ptr< ::NeXus::File> file_holder_type;
#else
typedef std::auto_ptr< ::NeXus::File> file_holder_type;
#endif

namespace Mantid
{
namespace API
{

/** FileBackedExperimentInfo : TODO: DESCRIPTION
Copyright &copy; 2015 ISIS Rutherford Appleton Laboratory, NScD Oak Ridge National Laboratory & European Spallation Source
This file is part of Mantid.
Mantid is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
Mantid is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
File change history is stored at: <https://github.com/mantidproject/mantid>
Code Documentation is available at: <http://doxygen.mantidproject.org>
*/
class DLLExport FileBackedExperimentInfo : public ExperimentInfo
{
public:
/// Constructor
FileBackedExperimentInfo(::NeXus::File file, std::string groupName);
/// Virtual destructor
virtual ~FileBackedExperimentInfo();

private:
void intialise();
::NeXus::File *file;
std::string groupName;
};


} // namespace API
} // namespace Mantid

#endif /* MANTID_API_FILEBACKEDEXPERIMENTINFO_H_ */
47 changes: 47 additions & 0 deletions Code/Mantid/Framework/API/src/FileBackedExperimentInfo.cpp
@@ -0,0 +1,47 @@
#include "MantidAPI/FileBackedExperimentInfo.h"

namespace Mantid
{
namespace API
{
namespace {
/// static logger object
Kernel::Logger g_log("FileBackedExperimentInfo");
}

//----------------------------------------------------------------------------------------------
/** Constructor
*/
FileBackedExperimentInfo::FileBackedExperimentInfo(::NeXus::File file, std::string groupName)
{
}

//----------------------------------------------------------------------------------------------
/** Destructor
*/
FileBackedExperimentInfo::~FileBackedExperimentInfo()
{
}

//------------------------------------------------------------------------------------------------------
// Private members
//------------------------------------------------------------------------------------------------------
/**
* Here we actually load the data
*/
void FileBackedExperimentInfo::intialise() {
std::string parameterStr;
try {
// Get the sample, logs, instrument
this->loadExperimentInfoNexus(file, parameterStr);
// Now do the parameter map
this->readParameterMap(parameterStr);
} catch (std::exception &e) {
g_log.information("Error loading section '" + groupName +
"' of nxs file.");
g_log.information(e.what());
}
}

} // namespace API
} // namespace Mantid
29 changes: 29 additions & 0 deletions Code/Mantid/Framework/API/test/FileBackedExperimentInfoTest.h
@@ -0,0 +1,29 @@
#ifndef MANTID_API_FILEBACKEDEXPERIMENTINFOTEST_H_
#define MANTID_API_FILEBACKEDEXPERIMENTINFOTEST_H_

#include <cxxtest/TestSuite.h>

#include "MantidAPI/FileBackedExperimentInfo.h"

using Mantid::API::FileBackedExperimentInfo;
using namespace Mantid::API;

class FileBackedExperimentInfoTest : public CxxTest::TestSuite
{
public:
// This pair of boilerplate methods prevent the suite being created statically
// This means the constructor isn't called when running other tests
static FileBackedExperimentInfoTest *createSuite() { return new FileBackedExperimentInfoTest(); }
static void destroySuite( FileBackedExperimentInfoTest *suite ) { delete suite; }


void test_Something()
{
TSM_ASSERT( "You forgot to write a test!", 0);
}


};


#endif /* MANTID_API_FILEBACKEDEXPERIMENTINFOTEST_H_ */

0 comments on commit b94b3f4

Please sign in to comment.