Flip Reference

 

Scribe Class Reference

Namespace

ohm::flip

Declared in

ohm/flip/Scribe.h

See Also

ohm::flip::TxSessionGuard

Overview

The Scribe class implements the undo/redo system in the Flip framework. One or more scribe can associated to any object of the model, which implements a per object history.

The most common use of a Scribe is on the root object of the model.

The following sections will only document the public API.

Partial Class Diagram

Methods Overview

Constructor

Manipulating

Undo/Redo

Methods

Scribe constructor

Constructs a Scribe over object . This will maintain an history associated to that object. object is usually the root object model.

               Scribe (Object & object);

annotate

Annotate a current transaction with a pair key / value . The transaction must be annotated before it is commited, should the transaction be part of the undo system.

A transaction may contain any number of key / value pair.

void           annotate (const std::string & key, const std::string & value);

has_undo / has_redo

Returns true is the undo (respectively redo) system contains at least one transaction, false otherwise.

bool           has_undo () const;
bool           has_redo () const;

get_undo_annotation / get_redo_annotation

Fills annotation_sptr with the first available transaction metadata of the undo (respectively redo) system.

void           get_undo_annotation (AnnotationSPtr & annotation_sptr);
void           get_redo_annotation (AnnotationSPtr & annotation_sptr);

This function does not pop the history, and is usually used to display the annotation in the GUI Menu Bar for the Undo and Redo menu item.

In a nutshell, the AnnotationSPtr type is a shared pointer on a key / value map;

undo_history / redo_history

Applies the first available transaction of the undo (respectively redo) system, and fills annotation_sptr with the ftransaction metadata.

Returns 0 if the operation succeeded, an error code otherwise.

int            undo_history (AnnotationSPtr & annotation_sptr);
int            redo_history (AnnotationSPtr & annotation_sptr);

This function will attempt to correct any error to at least fullfil structural validation when possible by modifying the transaction.

In a nutshell, the AnnotationSPtr type is a shared pointer on a key / value map;