LuciadCPillar 2023.1.04
|
This class can be used to save changes
to an IFeatureModel's
backend.
More...
#include <luciad/models/features/FeatureModelPersistenceManager.h>
Classes | |
class | Builder |
IFeatureModel implementations that have support for saving changes can use this class to create a FeatureModelPersistenceManager instance. More... | |
Public Member Functions | |
void | discardChanges () |
Discards the unsaved (in-memory) changes of the IFeatureModel , restoring the IFeatureModel's state back to that of its backend. More... | |
std::vector< FeatureChange > | getChanges () const |
Retrieves a list of all unsaved (in-memory) changes to the IFeatureModel . More... | |
std::optional< FeatureSaveErrorInfo > | saveChanges () |
Save the in-memory changes in the IFeatureModel's backend (for example a file or database). More... | |
Static Public Member Functions | |
static Builder | newBuilder () |
Returns a new FeatureModelPersistenceManager builder. More... | |
This class can be used to save changes
to an IFeatureModel's
backend.
The main goal of this class it to give more control over when changes are persisted. An important difference between the updater
and the FeatureModelPersistenceManager is the frequency at which they are used, with the FeatureModelPersistenceManager typically being used less often. In other words:
updater
typically only makes in-memory changes. These can occur in a high frequency and can be executed fast.For example: when dragging a point from one location to another in an editor configured to update on any change, many small updates
are done along the way. In contrast, a save
typically only happens when the editing is finished.
A FeatureModelPersistenceManager can be accessed through the model using IFeatureModel::getPersistenceManager
.
See this article for more information.
void luciad::FeatureModelPersistenceManager::discardChanges | ( | ) |
Discards the unsaved (in-memory) changes of the IFeatureModel
, restoring the IFeatureModel's
state back to that of its backend.
All observers
will be notified with a FeatureModelEvent
containing the FeatureChanges
necessary to go back to the backend's state.
std::vector< FeatureChange > luciad::FeatureModelPersistenceManager::getChanges | ( | ) | const |
Retrieves a list of all unsaved (in-memory) changes to the IFeatureModel
.
That is, the changes that need to be saved to the IFeatureModel's
backend to persist all in-memory changes. Multiple updates to the same feature will be condensed to a single FeatureChange
.
|
static |
Returns a new FeatureModelPersistenceManager builder.
std::optional< FeatureSaveErrorInfo > luciad::FeatureModelPersistenceManager::saveChanges | ( | ) |
Save the in-memory changes
in the IFeatureModel's backend (for example a file or database).
Typically, calling this method shouldn't modify the in-memory state of the model. So the feature model will not send out events through its observers
. In some cases however (depending on the model implementation), feature changes can occur while changes are saved. In that case, the model's observers need to be notified of those changes.
std::nullopt
on success, or error information on failure.