BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
viewmodelcontrollerbuilder.cpp
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/viewmodel/mvvm/factories/viewmodelcontrollerbuilder.cpp
6 //! @brief Implements 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 
20 #include <stdexcept>
21 
22 namespace ModelView {
23 
25 
27 
28 ViewModelControllerBuilder::operator std::unique_ptr<ViewModelController>()
29 {
30  if (!context.model)
31  throw std::runtime_error("Error in ViewModelController: undefined model");
32 
33  if (!context.children_strategy)
34  throw std::runtime_error("Error in ViewModelController: no children strategy defined.");
35 
36  if (!context.row_strategy)
37  throw std::runtime_error("Error in ViewModelController: no row strategy defined.");
38 
39  auto result = std::make_unique<ViewModelController>(context.model, context.view_model);
40  result->setChildrenStrategy(std::move(context.children_strategy));
41  result->setRowStrategy(std::move(context.row_strategy));
42 
43  return result;
44 }
45 
47 {
49  return *this;
50 }
51 
53 {
54  context.view_model = view_model;
55  return *this;
56 }
57 
59  std::unique_ptr<ChildrenStrategyInterface> children_strategy)
60 {
61  context.children_strategy = std::move(children_strategy);
62  return *this;
63 }
64 
66 ViewModelControllerBuilder::rowStrategy(std::unique_ptr<RowStrategyInterface> row_strategy)
67 {
68  context.row_strategy = std::move(row_strategy);
69  return *this;
70 }
71 
72 } // namespace ModelView
Defines class CLASS?
Main class to hold hierarchy of SessionItem objects.
Definition: sessionmodel.h:37
Base class for all view models to show content of SessionModel in Qt views.
Definition: viewmodelbase.h:31
Builder class for ViewModelController.
self & childrenStrategy(std::unique_ptr< ChildrenStrategyInterface > children_strategy)
self & viewModel(ViewModelBase *view_model)
self & rowStrategy(std::unique_ptr< RowStrategyInterface > row_strategy)
materialitems.h Collection of materials to populate MaterialModel.
Defines class CLASS?
Defines class CLASS?
std::unique_ptr< ChildrenStrategyInterface > children_strategy
std::unique_ptr< RowStrategyInterface > row_strategy
Defines class CLASS?
Defines class CLASS?