BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
path.h
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // qt-mvvm: Model-view-view-model framework for large GUI applications
4 //
5 //! @file mvvm/model/mvvm/model/path.h
6 //! @brief Defines class CLASS?
7 //!
8 //! @homepage http://www.bornagainproject.org
9 //! @license GNU General Public License v3 or higher (see COPYING)
10 //! @copyright Forschungszentrum Jülich GmbH 2020
11 //! @authors Gennady Pospelov et al, Scientific Computing Group at MLZ (see CITATION, AUTHORS)
12 //
13 // ************************************************************************************************
14 
15 #ifndef BORNAGAIN_MVVM_MODEL_MVVM_MODEL_PATH_H
16 #define BORNAGAIN_MVVM_MODEL_MVVM_MODEL_PATH_H
17 
18 #include "mvvm/model_export.h"
19 #include <string>
20 #include <vector>
21 
22 namespace ModelView {
23 
24 //! Supports navigation through SessionModel. Contains a chain of indexes that have to
25 //! be used to reach the desired SessionItem starting from the root item. Path class plays
26 //! a role of simplified QModelIndex for SessionModel. Used for undo/redo only.
27 
28 //! Example of tree:
29 //! - root path:""
30 //! - child path:"0"
31 //! - grandchild path:"0,0"
32 //! - grandchild path:"0,1"
33 //! - child path:"1"
34 
35 class MVVM_MODEL_EXPORT Path {
36 public:
37  using PathElement = int;
38  using container_t = std::vector<PathElement>;
39  using iterator = container_t::iterator;
40  using const_iterator = container_t::const_iterator;
41 
42  Path() = default;
43 
44  static Path fromString(const std::string& str);
45 
46  static Path fromVector(const std::vector<int>& data);
47 
48  std::string str() const;
49 
50  void append(PathElement element);
51  void prepend(PathElement element);
52 
53  iterator begin();
54  const_iterator begin() const;
55 
56  iterator end();
57  const_iterator end() const;
58 
59 private:
61 };
62 
63 } // namespace ModelView
64 
65 #endif // BORNAGAIN_MVVM_MODEL_MVVM_MODEL_PATH_H
Supports navigation through SessionModel.
Definition: path.h:35
std::vector< PathElement > container_t
Definition: path.h:38
Path()=default
container_t::iterator iterator
Definition: path.h:39
container_t::const_iterator const_iterator
Definition: path.h:40
int PathElement
Definition: path.h:37
container_t m_data
Definition: path.h:60
materialitems.h Collection of materials to populate MaterialModel.