BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
project_types.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/project/project_types.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_PROJECT_PROJECT_TYPES_H
16 #define BORNAGAIN_MVVM_MODEL_MVVM_PROJECT_PROJECT_TYPES_H
17 
18 #include "mvvm/model_export.h"
19 #include <functional>
20 #include <string>
21 #include <vector>
22 
23 namespace ModelView {
24 
25 class SessionModel;
26 
27 //! Possible user answers on question "Project was modified".
28 enum class SaveChangesAnswer { SAVE = 0, DISCARD = 1, CANCEL = 2 };
29 
30 //! Provides necessary information for Project construction.
31 
32 struct MVVM_MODEL_EXPORT ProjectContext {
33  //!< To notify about the change of the project with respect to what was written on disk.
34  using modified_callback_t = std::function<void()>;
35 
36  //! To ask for a vector of models to save/load to/from disk.
37  //! This is intentionally obtained via callback since save request might come after
38  //! the Project construction.
39  using models_callback_t = std::function<std::vector<SessionModel*>()>;
40 
43 };
44 
45 //! Defines the context to interact with the user regarding save/save-as/create-new project
46 //! scenarious.
47 
48 struct MVVM_MODEL_EXPORT UserInteractionContext {
49  //!< To ask the user to select existing directory, returns full path to the directory.
50  using select_dir_callback_t = std::function<std::string()>;
51 
52  //!< To ask the user to create a new directory, returns full path to the directory.
53  using create_dir_callback_t = std::function<std::string()>;
54 
55  //!< To ask the user what to do with modified project.
56  using answer_callback_t = std::function<SaveChangesAnswer()>;
57 
61 };
62 
63 } // namespace ModelView
64 
65 #endif // BORNAGAIN_MVVM_MODEL_MVVM_PROJECT_PROJECT_TYPES_H
materialitems.h Collection of materials to populate MaterialModel.
SaveChangesAnswer
Possible user answers on question "Project was modified".
Definition: project_types.h:28
Provides necessary information for Project construction.
Definition: project_types.h:32
std::function< void()> modified_callback_t
< To notify about the change of the project with respect to what was written on disk.
Definition: project_types.h:34
modified_callback_t m_modified_callback
Definition: project_types.h:41
std::function< std::vector< SessionModel * >()> models_callback_t
To ask for a vector of models to save/load to/from disk.
Definition: project_types.h:39
models_callback_t m_models_callback
Definition: project_types.h:42
Defines the context to interact with the user regarding save/save-as/create-new project scenarious.
Definition: project_types.h:48
std::function< std::string()> select_dir_callback_t
To ask the user to create a new directory, returns full path to the directory.
Definition: project_types.h:52
select_dir_callback_t m_select_dir_callback
Definition: project_types.h:58
std::function< SaveChangesAnswer()> answer_callback_t
Definition: project_types.h:56
create_dir_callback_t m_create_dir_callback
Definition: project_types.h:59
answer_callback_t m_answer_callback
Definition: project_types.h:60
std::function< std::string()> create_dir_callback_t
To ask the user what to do with modified project.
Definition: project_types.h:55