Flip Programming Guide

 

Using Cues

This chapter will describe the use of flip::Cue with the Flip framework.

In the following, we will show the step by step construction of an hypothetic MyClass class.

This chapter will assume that your company is called ACME making the application “Product”.

Overview

The Flip framework offers a flip::Cue class that allows to signal objects with an optional piece of opaque data. flip::Cue objects have inherently no value.

Cue is to a GUI push button what Bool is to a GUI toggle such as a check box.

Why Use a Cue ?

The Flip framework comes bundled with two signaling scheme.

The first signaling scheme is available through the send_signal of Object . This means that every Flip objects support signals inherently. An object signal is propagated to the other Flip threads of the client, but not to the other clients. They are not embedded in a transaction but are received through the virtual method signal in the document observers. Sending a signal is immediate.

On the other hand, the Cue signaling scheme implies that a Flip class must add a Cue in its member to access this feature. A Cue signal is propagated to the other Flip threads of the client, as well as the other clients and their Flip threads, as signaling a Cue is part of the transaction system. In particular, Cue signals are received through the virtual method document_changed of the document observers, like any other model change. Sending a signal throuh a Cue is tied to the transaction system, and may be delayed to the end of user input handling before it is sent.

The following table summarize the difference between the two signaling scheme.

send_signal

Cue

Other Flip Threads

Yes

Yes

Other Flip Clients

No

Yes

Transaction

No

Yes

Delivery

signal

document_changed

Sending

Immediate

Delayed (end of transaction)

Because object signals are not synchronized to transactions, signals may be received in an other order that the transaction one. For example if a client make a transaction and then send a signal, it is very likely that the signal will be received before the transaction, as the signal will be sent immediatly while the transaction will be sent when the user input call ends, which is after the signal is sent.

Therefore is synchronization is important, using a Cue is the solution. Because the Cue signal is sent to every clients, special precautions may have to be taken for the other clients to ignore the signal.

Differential Data Concept

Every atom of a Flip transaction represents a way to encode the difference between the old state and the new state of a basic Flip object.

While Cue has not internal value, the atom still expresses the implicit difference of the object, which sense is to the client appreciation.

In particular since every atom of a Flip transaction can be inverted, as this is how is handled the undo system as well as when rollbacking a transaction, the Cue supports the same system. Since the meaning of the implicit difference is left to the client, the meaning of the inverted implicit difference is also left to the client of the framework.

A Cue might be signaled multiple times in a transaction. Each signal is recorded. If the transaction is executed forward, querying the cue for an element will return direction 1 . If the executed backward, like in an undo, querying the cue for an element will return direction -1 .