BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
InstrumentCollection.h
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/Model/Device/InstrumentCollection.h
6 //! @brief Defines class InstrumentCollection
7 //!
8 //! @homepage http://www.bornagainproject.org
9 //! @license GNU General Public License v3 or higher (see COPYING)
10 //! @copyright Forschungszentrum Jülich GmbH 2018
11 //! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
12 //
13 // ************************************************************************************************
14 
15 #ifndef BORNAGAIN_GUI_MODEL_DEVICE_INSTRUMENTCOLLECTION_H
16 #define BORNAGAIN_GUI_MODEL_DEVICE_INSTRUMENTCOLLECTION_H
17 
18 #include <QStringList>
19 #include <QVector>
20 #include <functional>
21 #include <memory>
22 
23 class InstrumentItem;
24 class Instrument2DItem;
25 class Streamer;
26 
28 public:
30 
31  template <typename T>
33  {
34  auto* t = new T();
35  m_instruments << t;
36  return t;
37  }
38 
39  void removeInstrument(InstrumentItem* instrument);
40  void clear();
41 
42  void serialize(Streamer& s);
43 
44  void emplace_back(InstrumentItem* item) { m_instruments.push_back(item); } // TODO Qt6 emplace
45 
46  //! Inserts a deep copy (also of any non xml data in a pointwise axis)
47  //! The id will not be copied, but a new unique one will be created
48  //! Returns the newly created instrument.
50 
51  QVector<InstrumentItem*> collectedItems() const;
52  QVector<Instrument2DItem*> instrument2DItems() const;
53  QVector<InstrumentItem*>
54  instrumentItems(const std::function<bool(const InstrumentItem*)>& accept) const;
55 
56  InstrumentItem* findInstrumentById(const QString& instrumentId) const;
57  bool instrumentExists(const QString& instrumentId) const;
58 
59  QString suggestInstrumentName(const QString& baseName) const;
60  QStringList instrumentNames() const;
61 
62 private:
63  QVector<InstrumentItem*> m_instruments;
64 };
65 
66 #endif // BORNAGAIN_GUI_MODEL_DEVICE_INSTRUMENTCOLLECTION_H
InstrumentItem * findInstrumentById(const QString &instrumentId) const
void emplace_back(InstrumentItem *item)
void serialize(Streamer &s)
QVector< InstrumentItem * > instrumentItems(const std::function< bool(const InstrumentItem *)> &accept) const
QVector< InstrumentItem * > m_instruments
void removeInstrument(InstrumentItem *instrument)
QVector< Instrument2DItem * > instrument2DItems() const
QVector< InstrumentItem * > collectedItems() const
QString suggestInstrumentName(const QString &baseName) const
InstrumentItem * insertCopy(const InstrumentItem &source)
Inserts a deep copy (also of any non xml data in a pointwise axis) The id will not be copied,...
bool instrumentExists(const QString &instrumentId) const
QStringList instrumentNames() const
Abstract base class for instrument-specific item classes.
Supports serialization to or deserialization from QXmlStream.
Definition: Streamer.h:36
QString baseName(const QString &fileName)
Returns base name of file.
Definition: Path.cpp:133