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