CChangeNotifier.h
Go to the documentation of this file.
1 #ifndef istd_CChangeNotifier_included
2 #define istd_CChangeNotifier_included
3 
4 
5 // ACF includes
6 #include <istd/IChangeable.h>
7 
8 
9 namespace istd
10 {
11 
12 
22 {
23 public:
30  explicit CChangeNotifier(IChangeable* changeablePtr, const IChangeable::ChangeSet* changeSetPtr = &IChangeable::GetAnyChange());
32 
37  bool IsValid() const;
38 
42  void Reset();
47  void Abort();
48 
49 private:
50  // blocked copy constructor
51  CChangeNotifier(const CChangeNotifier& notifier);
52 
53  IChangeable* m_changeablePtr;
54  const IChangeable::ChangeSet& m_changeSet;
55 };
56 
57 
58 inline CChangeNotifier::CChangeNotifier(IChangeable* changeablePtr, const IChangeable::ChangeSet* changeSetPtr)
59 : m_changeablePtr(changeablePtr),
60  m_changeSet(*changeSetPtr)
61 {
62  Q_ASSERT(changeSetPtr != NULL);
63 
64  if (m_changeablePtr != NULL){
65  m_changeablePtr->BeginChanges(m_changeSet);
66  }
67 }
68 
69 
71 {
72  if (m_changeablePtr != NULL){
73  m_changeablePtr->EndChanges(m_changeSet);
74  }
75 }
76 
77 
78 } // namespace istd
79 
80 
81 #endif // !istd_CChangeNotifier_included
82 
83 
bool IsValid() const
Check if this pointer is valid.
static const ChangeSet & GetAnyChange()
Get anonymous change set.
Definition: IChangeable.h:381
CChangeNotifier(IChangeable *changeablePtr, const IChangeable::ChangeSet *changeSetPtr=&IChangeable::GetAnyChange())
Constructs the notifier.
void Reset()
Call update on attached object and detach it.
virtual void EndChanges(const ChangeSet &changeSet)
Ends the change transaction.
Definition: IChangeable.h:355
Common interface for data model objects, which can be changed.
Definition: IChangeable.h:24
Help class which provides the automatic update mechanism of the model.
#define NULL
Definition: istd.h:64
void Abort()
Similar like method Reset(), but it tries to avoid the update.
Set of change flags (its IDs).
Definition: IChangeable.h:30
virtual void BeginChanges(const ChangeSet &changeSet)
Starts the change transaction.
Definition: IChangeable.h:349

© 2007-2017 Witold Gantzke and Kirill Lepskiy