BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
SessionItemController.h
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/View/Common/SessionItemController.h
6 //! @brief Defines class SessionItemController
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_VIEW_COMMON_SESSIONITEMCONTROLLER_H
16 #define BORNAGAIN_GUI_VIEW_COMMON_SESSIONITEMCONTROLLER_H
17 
18 #include <QObject>
19 #include <functional>
20 
21 class SessionItem;
22 
23 //! Provides subscribe/unsubscribe mechanism for any QObject to track
24 //! time of life of SessionItem. Mainly intended for SessionItemWidget.
25 
26 class SessionItemController : public QObject {
27  Q_OBJECT
28 public:
29  using callback_t = std::function<void(void)>;
30 
31  explicit SessionItemController(QObject* prt);
32  ~SessionItemController() override;
33 
34  void setItem(SessionItem* item);
35 
37 
40 
41  void subscribe();
42  void unsubscribe();
43 
44 private:
45  void onItemDestroy();
46  void onControllerDestroy();
47  void subscribeParent();
48  void unsubscribeParent();
49 
54 };
55 
56 #endif // BORNAGAIN_GUI_VIEW_COMMON_SESSIONITEMCONTROLLER_H
Provides subscribe/unsubscribe mechanism for any QObject to track time of life of SessionItem....
void setUnsubscribeCallback(callback_t fun)
void setItem(SessionItem *item)
void setSubscribeCallback(callback_t fun)
std::function< void(void)> callback_t
void unsubscribeParent()
Calls additional callback on un.
void unsubscribe()
Fully unsubscribes the parent from listening item's signals. Controller stays active to track item de...
void subscribe()
Subscribe parent to item's signals.
Base class for a GUI data item.
Definition: SessionItem.h:204