BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
DatafieldDirHistory Class Reference

Description

Save history information for collection of items with non-XML data.

Definition at line 51 of file IOHistory.h.

Public Member Functions

 DatafieldDirHistory ()=default
 
bool contains (const SaveLoadInterface *item)
 
void markAsSaved (const SaveLoadInterface *item)
 
QStringList savedFileNames () const
 Returns list of file names used to save all items in a history. More...
 
bool wasModifiedSinceLastSave (const SaveLoadInterface *item)
 

Private Member Functions

DatafieldSaveInfo itemInfo (const SaveLoadInterface *item) const
 

Private Attributes

QVector< DatafieldSaveInfom_history
 

Constructor & Destructor Documentation

◆ DatafieldDirHistory()

DatafieldDirHistory::DatafieldDirHistory ( )
default

Member Function Documentation

◆ contains()

bool DatafieldDirHistory::contains ( const SaveLoadInterface item)

Definition at line 64 of file IOHistory.cpp.

65 {
66  for (auto& info : m_history)
67  if (info.item() == item)
68  return true;
69 
70  return false;
71 }
QVector< DatafieldSaveInfo > m_history
Definition: IOHistory.h:66

References m_history.

Referenced by markAsSaved(), and wasModifiedSinceLastSave().

◆ itemInfo()

DatafieldSaveInfo DatafieldDirHistory::itemInfo ( const SaveLoadInterface item) const
private

Definition at line 85 of file IOHistory.cpp.

86 {
87  for (const auto& info : m_history) {
88  if (info.item() == item)
89  return info;
90  }
91 
92  throw Error("DatafieldDirHistory::itemInfo() -> Error. No info exists.");
93 }

References Error, and m_history.

Referenced by wasModifiedSinceLastSave().

◆ markAsSaved()

void DatafieldDirHistory::markAsSaved ( const SaveLoadInterface item)

Definition at line 48 of file IOHistory.cpp.

49 {
50  if (contains(item))
51  throw Error("DatafieldDirHistory::markAsSaved() -> Error. "
52  "Already existing item.");
53  // Don't create any history info for empty items
54  if (item->containsNonXMLData())
56 }
bool contains(const SaveLoadInterface *item)
Definition: IOHistory.cpp:64
static DatafieldSaveInfo createSaved(const SaveLoadInterface *item)
Static method to create info for just saved item.
Definition: IOHistory.cpp:22
virtual bool containsNonXMLData() const =0
Checks if object owns non-XML data.

References contains(), SaveLoadInterface::containsNonXMLData(), DatafieldSaveInfo::createSaved(), Error, and m_history.

Referenced by DatafieldIOService::loadDataFiles(), and DatafieldIOService::save().

Here is the call graph for this function:

◆ savedFileNames()

QStringList DatafieldDirHistory::savedFileNames ( ) const

Returns list of file names used to save all items in a history.

Definition at line 75 of file IOHistory.cpp.

76 {
77  QStringList result;
78 
79  for (const auto& info : m_history)
80  result.append(info.fileName());
81 
82  return result;
83 }

References m_history.

Referenced by DatafieldIOService::save().

◆ wasModifiedSinceLastSave()

bool DatafieldDirHistory::wasModifiedSinceLastSave ( const SaveLoadInterface item)

Definition at line 58 of file IOHistory.cpp.

59 {
60  // non existing item is treated as modified since last save
61  return contains(item) ? itemInfo(item).wasModifiedSinceLastSave() : true;
62 }
DatafieldSaveInfo itemInfo(const SaveLoadInterface *item) const
Definition: IOHistory.cpp:85
bool wasModifiedSinceLastSave() const
Definition: IOHistory.cpp:33

References contains(), itemInfo(), and DatafieldSaveInfo::wasModifiedSinceLastSave().

Here is the call graph for this function:

Member Data Documentation

◆ m_history

QVector<DatafieldSaveInfo> DatafieldDirHistory::m_history
private

Definition at line 66 of file IOHistory.h.

Referenced by contains(), itemInfo(), markAsSaved(), and savedFileNames().


The documentation for this class was generated from the following files: