JUCE
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Defines
Public Member Functions
ScopedValueSetter< ValueType > Class Template Reference

Helper class providing an RAII-based mechanism for temporarily setting and then re-setting a value. More...

List of all members.

Public Member Functions

 ScopedValueSetter (ValueType &valueToSet, const ValueType &newValue)
 Creates a ScopedValueSetter that will immediately change the specified value to the given new value, and will then reset it to its original value when this object is deleted.
 ScopedValueSetter (ValueType &valueToSet, const ValueType &newValue, const ValueType &valueWhenDeleted)
 Creates a ScopedValueSetter that will immediately change the specified value to the given new value, and will then reset it to be valueWhenDeleted when this object is deleted.
 ~ScopedValueSetter ()

Detailed Description

template<typename ValueType>
class ScopedValueSetter< ValueType >

Helper class providing an RAII-based mechanism for temporarily setting and then re-setting a value.

E.g.

    int x = 1;

    {
        ScopedValueSetter setter (x, 2);

        // x is now 2
    }

    // x is now 1 again

    {
        ScopedValueSetter setter (x, 3, 4);

        // x is now 3
    }

    // x is now 4

Constructor & Destructor Documentation

template<typename ValueType >
ScopedValueSetter< ValueType >::ScopedValueSetter ( ValueType &  valueToSet,
const ValueType &  newValue 
)

Creates a ScopedValueSetter that will immediately change the specified value to the given new value, and will then reset it to its original value when this object is deleted.

template<typename ValueType >
ScopedValueSetter< ValueType >::ScopedValueSetter ( ValueType &  valueToSet,
const ValueType &  newValue,
const ValueType &  valueWhenDeleted 
)

Creates a ScopedValueSetter that will immediately change the specified value to the given new value, and will then reset it to be valueWhenDeleted when this object is deleted.

template<typename ValueType >
ScopedValueSetter< ValueType >::~ScopedValueSetter ( )

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