Mantid
|
An interface for objects that can be cached or saved to disk. More...
#include <ISaveable.h>
Public Member Functions | |
void | clearDataChanged () |
this method has to be called if the object has been discarded from memory and is not changed any more. More... | |
virtual void | clearDataFromMemory ()=0 |
remove objects data from memory More... | |
virtual void | flushData () const =0 |
Method to flush the data to disk and ensure it is written. More... | |
virtual size_t | getDataMemorySize () const =0 |
the data size kept in memory More... | |
virtual uint64_t | getFilePosition () const |
uint64_t | getFileSize () const |
Return the number of units this block occipies on file. More... | |
virtual uint64_t | getTotalDataSize () const =0 |
ISaveable () | |
Constructor More... | |
ISaveable (const ISaveable &other) | |
Copy constructor --> needed for std containers and not to copy mutexes Note setting isLoaded to false to break connection with the file object which is not copyale. More... | |
bool | isBusy () const |
bool | isDataChanged () const |
bool | isLoaded () const |
virtual void | load ()=0 |
Load the data - to be overriden. More... | |
virtual void | save () const =0 |
Save the data - to be overriden. More... | |
void | setBusy (bool On) |
@ set the data busy to prevent from removing them from memory. More... | |
void | setDataChanged () |
Call this method from the method which changes the object but keeps the object size the same to tell DiskBuffer to write it back the dataChanged ID is reset after save from the DataBuffer is emptied More... | |
void | setFilePosition (uint64_t newPos, size_t newSize, bool wasSaved) |
Sets the location of the object on HDD. More... | |
void | setLoaded (bool Yes) |
sets the value of the isLoad parameter, indicating that data from HDD have its image in memory More... | |
bool | wasSaved () const |
virtual | ~ISaveable ()=default |
Protected Attributes | |
bool | m_Busy |
a user needs to set this variable to true preventing from deleting data from buffer More... | |
bool | m_dataChanged |
a user needs to set this variable to true to allow DiskBuffer saving the object to HDD when it decides it suitable, if the size of iSavable object in cache is unchanged from the previous save/load operation More... | |
bool | m_isLoaded |
this boolean indicates, if the data have its copy in memory More... | |
bool | m_wasSaved |
this boolean indicates if the data were saved on HDD and have physical representation on it (though this representation may be incorrect as data changed in memory) More... | |
Private Member Functions | |
void | clearBufferState () |
clears the state of the object, and indicate that it is not stored in buffer any more More... | |
size_t | getBufferSize () const |
return the amount of memory, this object had when it was stored in buffer last time; More... | |
boost::optional< std::list< ISaveable * >::iterator > & | getBufPostion () |
returns the iterator pointing to the position of this object within the memory to-write buffer More... | |
void | saveAt (uint64_t newPos, uint64_t newSize) |
save at specific file location the specific amount of data; used by DiskBuffer which asks this object where to save it and calling overloaded object specific save operation above More... | |
size_t | setBufferPosition (std::list< ISaveable * >::iterator bufPosition) |
sets the iterator pointing to the location of this object in the memory buffer to write later More... | |
void | setBufferSize (size_t newSize) |
Private Attributes | |
size_t | m_BufMemorySize |
boost::optional< std::list< ISaveable * >::iterator > | m_BufPosition |
uint64_t | m_fileIndexStart |
Start point in the NXS file where the events are located. More... | |
uint64_t | m_fileNumEvents |
Number of events saved in the file, after the start index location. More... | |
std::mutex | m_setter |
Friends | |
class | DiskBuffer |
the functions below have to be availible to DiskBuffer and nobody else. More... | |
An interface for objects that can be cached or saved to disk.
This is implemented by MDBox and is used in the in-memory cache of file-backed MDEventWorkspaces.
Definition at line 28 of file ISaveable.h.
Mantid::Kernel::ISaveable::ISaveable | ( | ) |
Constructor
Definition at line 13 of file ISaveable.cpp.
Mantid::Kernel::ISaveable::ISaveable | ( | const ISaveable & | other | ) |
Copy constructor --> needed for std containers and not to copy mutexes Note setting isLoaded to false to break connection with the file object which is not copyale.
Definition at line 21 of file ISaveable.cpp.
|
virtualdefault |
|
private |
clears the state of the object, and indicate that it is not stored in buffer any more
Definition at line 79 of file ISaveable.cpp.
References m_BufMemorySize, m_BufPosition, and m_setter.
Referenced by Mantid::Kernel::DiskBuffer::objectDeleted().
|
inline |
this method has to be called if the object has been discarded from memory and is not changed any more.
It expected to be called from clearDataFromMemory.
Definition at line 90 of file ISaveable.h.
|
pure virtual |
remove objects data from memory
Implemented in Mantid::DataObjects::MDBoxSaveable.
Referenced by saveAt().
|
pure virtual |
Method to flush the data to disk and ensure it is written.
Implemented in Mantid::DataObjects::MDBoxSaveable.
|
inlineprivate |
return the amount of memory, this object had when it was stored in buffer last time;
Definition at line 165 of file ISaveable.h.
Referenced by Mantid::Kernel::DiskBuffer::objectDeleted(), and Mantid::Kernel::DiskBuffer::toWrite().
|
inlineprivate |
returns the iterator pointing to the position of this object within the memory to-write buffer
Definition at line 162 of file ISaveable.h.
Referenced by Mantid::Kernel::DiskBuffer::objectDeleted(), and Mantid::Kernel::DiskBuffer::toWrite().
|
pure virtual |
the data size kept in memory
Implemented in Mantid::DataObjects::MDBoxSaveable.
Referenced by setBufferPosition(), and Mantid::Kernel::DiskBuffer::toWrite().
|
inlinevirtual |
|
inline |
Return the number of units this block occipies on file.
Definition at line 38 of file ISaveable.h.
Referenced by Mantid::DataObjects::MDBoxSaveable::load(), and Mantid::Kernel::DiskBuffer::objectDeleted().
|
pure virtual |
Implemented in Mantid::DataObjects::MDBoxSaveable.
|
inline |
Definition at line 68 of file ISaveable.h.
|
inline |
Definition at line 79 of file ISaveable.h.
|
inline |
Definition at line 56 of file ISaveable.h.
|
pure virtual |
Load the data - to be overriden.
Implemented in Mantid::DataObjects::MDBoxSaveable.
Referenced by saveAt().
|
pure virtual |
Save the data - to be overriden.
Implemented in Mantid::DataObjects::MDBoxSaveable.
Referenced by saveAt().
|
private |
save at specific file location the specific amount of data; used by DiskBuffer which asks this object where to save it and calling overloaded object specific save operation above
private function which used by the disk buffer to save the contents of the object
newPos | – new position to save object to |
newSize | – new size of the saveable object |
Definition at line 49 of file ISaveable.cpp.
References clearDataFromMemory(), load(), m_fileIndexStart, m_fileNumEvents, m_setter, save(), and wasSaved().
|
private |
sets the iterator pointing to the location of this object in the memory buffer to write later
Method stores the position of the object in Disc buffer and returns the size of this object for disk buffer to store.
bufPosition | – the allocator which specifies the position of the object in the list of objects to write |
Definition at line 69 of file ISaveable.cpp.
References getDataMemorySize(), m_BufMemorySize, m_BufPosition, and m_setter.
Referenced by Mantid::Kernel::DiskBuffer::toWrite().
|
inlineprivate |
Definition at line 166 of file ISaveable.h.
Referenced by Mantid::Kernel::DiskBuffer::toWrite().
|
inline |
@ set the data busy to prevent from removing them from memory.
The process which does that should clean the data when finished with them
Definition at line 71 of file ISaveable.h.
|
inline |
Call this method from the method which changes the object but keeps the object size the same to tell DiskBuffer to write it back the dataChanged ID is reset after save from the DataBuffer is emptied
Definition at line 83 of file ISaveable.h.
void Mantid::Kernel::ISaveable::setFilePosition | ( | uint64_t | newPos, |
size_t | newSize, | ||
bool | wasSaved | ||
) |
Sets the location of the object on HDD.
Set the start/end point in the file where the events are located.
newPos | :: start point, |
newSize | :: number of events in the file |
wasSaved | :: flag to mark if the info was saved, by default it does |
Definition at line 35 of file ISaveable.cpp.
References m_fileIndexStart, m_fileNumEvents, m_setter, m_wasSaved, and wasSaved().
|
inline |
sets the value of the isLoad parameter, indicating that data from HDD have its image in memory
Yes | – boolean true or false –usually only load functiomn should set it to true |
Definition at line 64 of file ISaveable.h.
Referenced by Mantid::DataObjects::MDBoxSaveable::load().
|
inline |
Definition at line 47 of file ISaveable.h.
Referenced by Mantid::Kernel::DiskBuffer::objectDeleted(), Mantid::DataObjects::MDBoxSaveable::save(), saveAt(), and setFilePosition().
|
friend |
the functions below have to be availible to DiskBuffer and nobody else.
To highlight this we make them private
Definition at line 151 of file ISaveable.h.
|
private |
Definition at line 143 of file ISaveable.h.
Referenced by clearBufferState(), and setBufferPosition().
|
private |
Definition at line 140 of file ISaveable.h.
Referenced by clearBufferState(), and setBufferPosition().
|
protected |
a user needs to set this variable to true preventing from deleting data from buffer
Definition at line 122 of file ISaveable.h.
|
protected |
a user needs to set this variable to true to allow DiskBuffer saving the object to HDD when it decides it suitable, if the size of iSavable object in cache is unchanged from the previous save/load operation
Definition at line 128 of file ISaveable.h.
|
private |
Start point in the NXS file where the events are located.
Definition at line 145 of file ISaveable.h.
Referenced by saveAt(), and setFilePosition().
|
private |
Number of events saved in the file, after the start index location.
Definition at line 147 of file ISaveable.h.
Referenced by saveAt(), and setFilePosition().
|
protected |
this boolean indicates, if the data have its copy in memory
Definition at line 135 of file ISaveable.h.
Referenced by Mantid::DataObjects::MDBoxSaveable::load().
|
private |
Definition at line 173 of file ISaveable.h.
Referenced by clearBufferState(), saveAt(), setBufferPosition(), and setFilePosition().
|
mutableprotected |
this boolean indicates if the data were saved on HDD and have physical representation on it (though this representation may be incorrect as data changed in memory)
Definition at line 133 of file ISaveable.h.
Referenced by Mantid::DataObjects::MDBoxSaveable::save(), and setFilePosition().