OpendTect  6.3
i_qptr.h
Go to the documentation of this file.
1 #ifndef i_qptr_h
2 #define i_qptr_h
3 
4 /*+
5 ________________________________________________________________________
6 
7  (C) dGB Beheer B.V.; (LICENSE) http://opendtect.org/OpendTect_license.txt
8  Author: Kristofer Tingdahl
9  Date: November 2012
10 ________________________________________________________________________
11 
12 -*/
13 
14 #include "notify.h"
15 #include <QObject>
16 
17 QT_BEGIN_NAMESPACE
18 
24 class i_QPtrImpl : public QObject, public CallBacker
25 {
26  Q_OBJECT
27 
28 public:
29 
32 
33  QObject* ptr() { return sender_; }
34  const QObject* ptr() const { return sender_; }
35 
36 
37  operator QObject*() { return sender_; }
38  operator const QObject*() const { return sender_; }
39  QObject* operator->() { return sender_; }
40  QObject* operator->() const { return sender_; }
41  QObject* operator=(QObject* qo) { set( qo ); return qo;}
42 
43  Threads::Lock& objLock() { return lock_; }
44 
45 
46  void set(QObject* qo);
47  i_QPtrImpl( QObject* sndr = 0 );
48  ~i_QPtrImpl();
49 
50 private:
51 
52  QObject* sender_;
53 
54 private slots:
55 
56  void destroyed( QObject* )
57  {
58  notifier_.trigger();
59  Threads::Locker lckr( lock_ );
60  sender_ = 0;
61  }
62 
63 };
64 
65 QT_END_NAMESPACE
66 
67 #endif
Inherit from this class to be able to send and/or receive CallBacks.
Definition: callback.h:182
Locks the lock, shutting out access from other threads if needed.
Definition: threadlock.h:83
QObject * operator=(QObject *qo)
Definition: i_qptr.h:41
A lock of a type that (hopefully) suits your needs. To use it, you need the Locker class...
Definition: threadlock.h:51
Notifier< i_QPtrImpl > notifier_
Definition: i_qptr.h:30
Threads::Lock & objLock()
Definition: i_qptr.h:43
void trigger()
Definition: notify.h:128
Helper class for QPtr to relay Qt&#39;s messages. Internal object, to hide Qt&#39;s signal/slot mechanism...
Definition: i_qptr.h:24
Threads::Lock lock_
Definition: i_qptr.h:31
const QObject * ptr() const
Definition: i_qptr.h:34
i_QPtrImpl(QObject *sndr=0)
QObject * operator->() const
Definition: i_qptr.h:40
QObject * operator->()
Definition: i_qptr.h:39
QObject * ptr()
Definition: i_qptr.h:33
QObject * sender_
Definition: i_qptr.h:52
void destroyed(QObject *)
Definition: i_qptr.h:56

Generated at for the OpendTect seismic interpretation project. Copyright (C): dGB Beheer B. V. 2017