Skip to content

Commit

Permalink
refs #6449 presumably completed all new saveable logic
Browse files Browse the repository at this point in the history
  • Loading branch information
abuts committed Apr 16, 2013
1 parent dd79a89 commit 6d35b14
Show file tree
Hide file tree
Showing 4 changed files with 194 additions and 186 deletions.
1 change: 1 addition & 0 deletions Code/Mantid/Framework/Kernel/inc/MantidKernel/ISaveable.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ namespace Kernel
virtual void setFilePosition(uint64_t newPos,size_t newSize,bool wasSaved)=0;
//-----------------------------------------------------------------------------------------------


/// Save the data - to be overriden
virtual void save()const =0;

Expand Down
14 changes: 12 additions & 2 deletions Code/Mantid/Framework/MDEvents/src/MDBox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace Mantid
namespace MDEvents
{


/**Destructor */
TMDE(MDBox)::~MDBox()
{
if(m_Saveable)delete m_Saveable;
Expand Down Expand Up @@ -56,6 +56,11 @@ namespace MDEvents
throw std::invalid_argument("MDBox::ctor(): controller passed has the wrong number of dimensions.");

if(nBoxEvents!=UNDEF_SIZET) data.reserve(nBoxEvents);

if(splitter->isFileBacked())
this->setFileBacked();


}


Expand All @@ -69,7 +74,12 @@ namespace MDEvents
data(other.data),
m_bIsMasked(other.m_bIsMasked)
{
//TODO: inheriting Saveable logic on the basis of otherBC
if(otherBC) // may be absent in some tests but generally present
{
if(otherBC->isFileBacked())
this->setFileBacked();

}
}


Expand Down
35 changes: 18 additions & 17 deletions Code/Mantid/Framework/MDEvents/src/MDBoxSaveable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@ namespace MDEvents
}

//-----------------------------------------------------------------------------------------------
/** Call to save the data (if needed) and release the memory used.
/** Physical save the whole data. Tries to load any previous data from HDD
* Called from the DiskBuffer.
* If called directly presumes to know its file location and [TODO: refactor this] needs the file to be open correctly on correct group
*/
void MDBoxSaveable::save()const
{
Expand All @@ -35,6 +34,23 @@ namespace MDEvents

m_MDNode->saveAt(fileIO,this->getFilePosition());

}

/** Loads the data from HDD if these data were not loaded before. */
void MDBoxSaveable::load()
{
API::IBoxControllerIO *fileIO = m_MDNode->getBoxController()->getFileIO();

// Is the data in memory right now (cached copy)?
if (!m_isLoaded)
{
m_MDNode->loadAndAddFrom(fileIO,this->m_fileIndexStart,this->m_fileNumEvents);
this->m_isLoaded = true;
}

}

// old save parts
// // std::cout << "MDBox ID " << this->getId() << " being saved." << std::endl;
//
//
Expand All @@ -59,22 +75,7 @@ namespace MDEvents
// if(data.size()>0) throw std::runtime_error(" Attempt to save undefined event");
//
//
}

//
void MDBoxSaveable::load()
{
API::IBoxControllerIO *fileIO = m_MDNode->getBoxController()->getFileIO();

// Is the data in memory right now (cached copy)?
if (!m_isLoaded)
{
m_MDNode->loadAndAddFrom(fileIO,this->m_fileIndexStart,this->m_fileNumEvents);
this->m_isLoaded = true;
}

}


//
// //---------------------------------------------------------------------------------------------
Expand Down

0 comments on commit 6d35b14

Please sign in to comment.