1 | /*
|
---|
2 | * QtObservedAtom.hpp
|
---|
3 | *
|
---|
4 | * Created on: Oct 28, 2015
|
---|
5 | * Author: heber
|
---|
6 | */
|
---|
7 |
|
---|
8 |
|
---|
9 | #ifndef QTOBSERVEDATOM_HPP_
|
---|
10 | #define QTOBSERVEDATOM_HPP_
|
---|
11 |
|
---|
12 | // include config.h
|
---|
13 | #ifdef HAVE_CONFIG_H
|
---|
14 | #include <config.h>
|
---|
15 | #endif
|
---|
16 |
|
---|
17 | #include <QtGui/QWidget>
|
---|
18 |
|
---|
19 |
|
---|
20 | #include <boost/shared_ptr.hpp>
|
---|
21 |
|
---|
22 | #include "CodePatterns/Observer/Observer.hpp"
|
---|
23 |
|
---|
24 | #include "UIElements/Qt4/InstanceBoard/ObservedValue_types.hpp"
|
---|
25 | #include "UIElements/Qt4/InstanceBoard/ObservedValuesContainer.hpp"
|
---|
26 | #include "types.hpp"
|
---|
27 |
|
---|
28 | class QtObservedInstanceBoard;
|
---|
29 |
|
---|
30 | /** This instance is the ObservedValue representation of a World's atom.
|
---|
31 | *
|
---|
32 | * Due to the signal/slot mechanism and its delays, lifetime of objects in the
|
---|
33 | * World and their QtGui representation cannot directly be related (without
|
---|
34 | * slowing down Actions just for having the representation up to speed).
|
---|
35 | * Hence, the required information for displaying and representing these
|
---|
36 | * objects must be contained in an extra instance.
|
---|
37 | *
|
---|
38 | * This is the instance for information about a particular atom.
|
---|
39 | */
|
---|
40 | class QtObservedAtom : public QWidget, public Observer
|
---|
41 | {
|
---|
42 | Q_OBJECT
|
---|
43 |
|
---|
44 | //!> ObservedValuesContainer needs to access private cstor and dstor
|
---|
45 | friend class ObservedValuesContainer<QtObservedAtom, atomId_t>;
|
---|
46 | //!> QtObservedInstanceBoard needs to access private cstor and dstor
|
---|
47 | friend class QtObservedInstanceBoard;
|
---|
48 |
|
---|
49 | //!> typedef for instance wrapped in shared ptr
|
---|
50 | typedef boost::shared_ptr<QtObservedAtom> ptr;
|
---|
51 |
|
---|
52 | /** Cstor of QtObservedAtom.
|
---|
53 | *
|
---|
54 | * \param _obsvalues ref to set of observed values for this instance
|
---|
55 | * \param _parent Qt parent to automatically destroy when parent is destroyed
|
---|
56 | */
|
---|
57 | QtObservedAtom(
|
---|
58 | const ObservedValues_t &_obsvalues,
|
---|
59 | QWidget * _parent=0);
|
---|
60 |
|
---|
61 | public:
|
---|
62 |
|
---|
63 | /** Dstor of QtObservedAtom.
|
---|
64 | *
|
---|
65 | */
|
---|
66 | ~QtObservedAtom();
|
---|
67 |
|
---|
68 | // Observer functions
|
---|
69 | void update(Observable *publisher);
|
---|
70 | void subjectKilled(Observable *publisher);
|
---|
71 | void recieveNotification(Observable *publisher, Notification_ptr notification);
|
---|
72 |
|
---|
73 | signals:
|
---|
74 |
|
---|
75 | private slots:
|
---|
76 |
|
---|
77 |
|
---|
78 | private:
|
---|
79 | //!> internal reference to ObservedValues held by QtObservedInstanceBoard
|
---|
80 | const ObservedValues_t &obsvalues;
|
---|
81 | };
|
---|
82 |
|
---|
83 |
|
---|
84 | #endif /* QTOBSERVEDATOM_HPP_ */
|
---|