App::AtomicPropertyChangeInterface< P > Class Template Reference

A template class that is used to inhibit multiple nested calls to aboutToSetValue/hasSetValue for properties. More...

#include <Property.h>

Classes

class  AtomicPropertyChange
 

Protected Member Functions

 AtomicPropertyChangeInterface ()
 

Protected Attributes

bool hasChanged
 
int signalCounter
 Counter for invoking transaction start/stop. More...
 

Detailed Description

template<class P>
class App::AtomicPropertyChangeInterface< P >

A template class that is used to inhibit multiple nested calls to aboutToSetValue/hasSetValue for properties.

A template class that is used to inhibit multiple nested calls to aboutToSetValue/hasSetValue for properties, and only invoke it on change and last time it is needed. This is useful in cases where you want to change multiple values in a property "atomically", using possibly multiple primitive functions that normally would trigger aboutToSetValue/hasSetValue calls on their own.

To use, inherit privately from the AtomicPropertyChangeInterface class, using your class name as the template argument. In all cases where you normally would call aboutToSetValue/hasSetValue before and after a change, create an AtomicPropertyChange object. The default constructor assume you are about to change the property and will call property's aboutToSetValue() if the property has not been marked as changed before by any other AtomicPropertyChange instances in current call stack. You can pass 'false' as the a second argument to the constructor, and manually call AtomicPropertyChange::aboutToChange() before actual change, this enables you to prevent unnecessary property copy for undo/redo where there is actual changes. AtomicPropertyChange will guaranetee calling hasSetValue() when the last instance in the current call stack is destroyed.

One thing to take note is that, because C++ does not allow throwing exception in destructor, any exception thrown when calling property's hasSetValue() will be caught and swallowed. To allow exception propagation, you can manually call AtomicPropertyChange::tryInvoke(). If the condition is satisfied, it will call hasSetValue() that allows exception propagation.

Constructor & Destructor Documentation

◆ AtomicPropertyChangeInterface()

template<class P >
App::AtomicPropertyChangeInterface< P >::AtomicPropertyChangeInterface ( )
protected

Member Data Documentation

◆ hasChanged

template<class P >
bool App::AtomicPropertyChangeInterface< P >::hasChanged
protected

◆ signalCounter

template<class P >
int App::AtomicPropertyChangeInterface< P >::signalCounter
protected

Counter for invoking transaction start/stop.


The documentation for this class was generated from the following file: