Flip Overview

Interfacing with the Model

When interfacing with the model, the code can be separated in two parts:

  1. the part that control the model
  2. the part that reacts to model changes

Controlling the Model

Controlling the model is done by directly changing the model, just as you would do with regular classes.

If a class Element has two members position and length, changing the position and the length of the element is as simple as:

element.position = some_position;
element.length = some_length;

The members used by classes are actually Flip objects. They are proxies which handle changes to the model.

For example, to write a class with a member:

int	position;

You would transform it to:

flip::Int64	position;

And to write a class with a list of members:

std::list<Element>	element_arr;

You would transform it to:

flip::Array<Element> element_arr;

Manipulating Flip containers is very close to the conventions used by the C++ standard library (STL). Adding an element is done with insert, and erasing an element is done with erase. Other functions are provided in a monolithic way like in the original STL in order to ensure that developers will feel right at home.

Observing the Model

When a client modifies its own model or receives a modification (transaction) of the model from another client from the server, the model is directly modified.

The client of the model will have registered one or more observers to be notified when the model changes. These observer are called with the model's root object passed as a argument.

When the client observer is called, Flip maintains the previous version of the model as well as the current one as applied by the transaction. This allows the client to know:

The client is then responsible for parsing the model tree to ensure that its local representation of the model matches the one from Flip.

Furthermore, Flip was designed to make this task as simple as possible. The model tree can be parsed in any direction, parsed multiple times, and so on. Multiple represented objects can also be attached to Flip objects. We have also supplied some code patterns that can simplify your work.

As long as the model client does not exit during the observer callback, Flip still maintains the old and current versions of the model. Each Flip object, as well as your custom classes, have an added() method which can be called to see if an object or its compound objects have been modified. This call is also recursive.

Whether your local model uses object pointers, references, or IDs, you can attach it to any Flip object. This architecture offers simple but powerful interoperability with Flip and your GUI or external libraries.