OpendTect-6_4  6.4
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  RCS: $Id$
11 ________________________________________________________________________
12 
13 -*/
14 
15 #include "callback.h"
16 #include "threadlock.h"
17 #include <QObject>
18 
19 QT_BEGIN_NAMESPACE
20 
26 class i_QPtrImpl : public QObject, public CallBacker
27 {
28  Q_OBJECT
29 
30 public:
31 
34 
35  QObject* ptr() { return sender_; }
36  const QObject* ptr() const { return sender_; }
37 
38 
39  operator QObject*() { return sender_; }
40  operator const QObject*() const { return sender_; }
41  QObject* operator->() { return sender_; }
42  QObject* operator->() const { return sender_; }
43  QObject* operator=(QObject* qo) { set( qo ); return qo;}
44 
45  Threads::Lock& objLock() { return lock_; }
46 
47 
48  void set(QObject* qo);
49  i_QPtrImpl( QObject* sndr = 0 );
50  ~i_QPtrImpl();
51 
52 private:
53 
54  QObject* sender_;
55 
56 private slots:
57 
58  void destroyed( QObject* )
59  {
60  notifier_.trigger();
61  Threads::Locker lckr( lock_ );
62  sender_ = 0;
63  }
64 
65 };
66 
67 QT_END_NAMESPACE
68 
69 #endif
To be able to send and/or receive CallBacks, inherit from this class.
Definition: callback.h:272
Locks the lock, shutting out access from other threads if needed.
Definition: threadlock.h:85
QObject * operator=(QObject *qo)
Definition: i_qptr.h:43
A lock of a type that (hopefully) suits your needs. To use it, you need the Locker class...
Definition: threadlock.h:53
Notifier< i_QPtrImpl > notifier_
Definition: i_qptr.h:32
Threads::Lock & objLock()
Definition: i_qptr.h:45
Helper class for QPtr to relay Qt&#39;s messages. Internal object, to hide Qt&#39;s signal/slot mechanism...
Definition: i_qptr.h:26
Threads::Lock lock_
Definition: i_qptr.h:33
const QObject * ptr() const
Definition: i_qptr.h:36
i_QPtrImpl(QObject *sndr=0)
QObject * operator->() const
Definition: i_qptr.h:42
QObject * operator->()
Definition: i_qptr.h:41
QObject * ptr()
Definition: i_qptr.h:35
void trigger(T &t)
Definition: callback.h:258
QObject * sender_
Definition: i_qptr.h:54
void destroyed(QObject *)
Definition: i_qptr.h:58

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