C12Adapter Opensource C++ Interface
|
Class that helps preserve a property value outside a local C++ scope. More...
Public Member Functions | |
MObjectPropertySavior (MObject *obj, const MStdString &propertyName) | |
Constructor that accepts the object and the name of the property that has to be saved. More... | |
MObjectPropertySavior (MObject *obj, const MStdString &propertyName, const MVariant &value) | |
Constructor that accepts the object, the property name, and the new value of the property. More... | |
~MObjectPropertySavior () | |
Destructor that restores the value of the property to its original value. More... | |
Class that helps preserve a property value outside a local C++ scope.
The constructor saves the given property by name, and the destructor restores it. The type of the variable to manipulate shall be assignable, or a compile error will result from the usage attempt. Typical use case:
Exception behavior has these specifics:
MObjectPropertySavior::MObjectPropertySavior | ( | MObject * | obj, |
const MStdString & | propertyName | ||
) |
Constructor that accepts the object and the name of the property that has to be saved.
The constructor will fetch the property value by name and store it for later restoration in destructor.
obj | Object for which the property has to be preserve. |
propertyName | Name of the property to preserve. Such property should exist in object, and be read/write. |
MObjectPropertySavior::MObjectPropertySavior | ( | MObject * | obj, |
const MStdString & | propertyName, | ||
const MVariant & | value | ||
) |
Constructor that accepts the object, the property name, and the new value of the property.
The constructor will store the address of the value and the value itself, so it can be restored in the destructor. Then it will assign a new value given as parameter. This constructor is a convenient shortcut of the following:
which can be written in a new line:
The constructor will fetch the property value by name and store it for later restoration in destructor.
obj | Object for which the property has to be preserve. |
propertyName | Name of the property to preserve. Such property should exist in object, and be read/write. |
value | New value to be assigned to object property, should satisfy the requirements for such property. |
MObjectPropertySavior::~MObjectPropertySavior | ( | ) |
Destructor that restores the value of the property to its original value.
As value savior is often created on the stack there is no necessity to call its destructor directly or by means of operator
delete
.