Mantid
Loading...
Searching...
No Matches
MDBoxSaveable.cpp
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 +
9
10namespace Mantid::DataObjects {
11
12MDBoxSaveable::MDBoxSaveable(API::IMDNode *const Host) : m_MDNode(Host) {}
13
16
17//-----------------------------------------------------------------------------------------------
21void MDBoxSaveable::save() const {
25 if (this->wasSaved()) {
26 auto loader = const_cast<MDBoxSaveable *>(this);
27 loader->load();
28 }
29
30 m_MDNode->saveAt(fileIO, this->getFilePosition());
31 this->m_wasSaved = true;
32}
33
38 // Is the data in memory right now (cached copy)?
39 if (!m_isLoaded) {
41 m_MDNode->loadAndAddFrom(fileIO, this->getFilePosition(), this->getFileSize());
42 this->setLoaded(true);
43 }
44}
45} // namespace Mantid::DataObjects
IBoxControllerIO * getFileIO()
returns the pointer to the class, responsible for fileIO operations;
The header describes interface to IO Operations perfomed by the box controller May be replaced by a b...
virtual void flushData() const =0
flush the IO buffers
virtual void loadAndAddFrom(API::IBoxControllerIO *const, uint64_t, size_t, std::vector< coord_t > &)=0
Load the additional box data of specified size from the disk location provided using the class,...
virtual void saveAt(API::IBoxControllerIO *const, uint64_t) const =0
Save the box at specific disk position using the class, respoinsible for the file IO.
virtual Mantid::API::BoxController * getBoxController() const =0
get box controller
Two classes responsible for implementing methods which automatically save/load MDBox in conjuction wi...
Definition: MDBoxSaveable.h:25
void load() override
Load the data which are not in memory yet and merge them with the data in memory;.
void save() const override
Save the data to the place, specified by the object.
MDBoxSaveable(API::IMDNode *const)
void flushData() const override
Method to flush the data to disk and ensure it is written.
virtual uint64_t getFilePosition() const
Definition: ISaveable.h:36
bool wasSaved() const
Definition: ISaveable.h:47
uint64_t getFileSize() const
Return the number of units this block occipies on file.
Definition: ISaveable.h:38
void setLoaded(bool Yes)
sets the value of the isLoad parameter, indicating that data from HDD have its image in memory
Definition: ISaveable.h:64
bool m_isLoaded
this boolean indicates, if the data have its copy in memory
Definition: ISaveable.h:135
bool m_wasSaved
this boolean indicates if the data were saved on HDD and have physical representation on it (though t...
Definition: ISaveable.h:133