Flip Reference

 

DocumentClient Class Reference

Namespace

ohm::flip

Inherits from

ohm::flip::DocumentBase

Declared in

ohm/flip/DocumentClient.h

Overview

The DocumentClient class implements a Flip document used on the client side. The following sections will only document the public API.

Partial Class Diagram

Methods Overview

Constructor

Destructor

Observing

Manipulating

Scribe (Undo System)

Reading/Writing

Methods

DocumentClient constructor

Constructs a DocumentClient .

               DocumentClient (
                  DocumentClientMasterSlot & parent,
                  const std::string & user_name,
                  archi::Int32 thread_id
               );

parent denotes the DocumentClientMasterSlot to which the document is attached. It represents a Flip thread.

restore

Restore a DocumentClient .

void           restore ();

bind

Bind the DocumentObserver to the document.

void           bind (DocumentObserverMaster & observer);

After the document is bound, the observer will start to receive document model changes through the document_changed message, and signals through the signal message.

The observer will be automatically unbound when the document is released.

Note:The document only accepts one DocumentObserver .

AutoUserInputs class

Implements an automatic way to let know the Flip framework that a transaction begin might occur, or that a transaction comes to its end, and acts as a safe guard.

            AutoUserInputs (DocumentBase & document);
virtual     ~AutoUserInputs ();

Each function that might change the model must be surrounded with an automatic variable of the type of this class. Usually this is done in the top function that handles user inputs or timers.

ListingExample of implementation

void  MySystemView::handle_user_inputs (SystemEvent & event)
{
   ohm::flip::AutoUserInputs auto_ui (_document);
   switch (event._type)
   {
      [...]
   }
}

add

Adds a Scribe to the document for the current transaction.

The Scribe must be added before each transaction that must be part of the undo system. In particular, if no Scribe is added before the transaction is made, then the transaction will not be part of the undo system, which is sometimes wanted, for example when scrolling in a document.

void           add (Scribe & scribe);

The Scribe system is what implements the undo/redo system in the Flip framework.

remove

Removes a Scribe from the document.

void           remove (Scribe & scribe);

The Scribe system is what implements the undo/redo system in the Flip framework.

read

Reads a document from data .

void           read_document (const DataMaster & doc_data);

In a nutshell, DataMaster implements a shared pointer that works cross operating system processes.

write_document

Writes a document and returns it into a shared pointer type object, without any latent transactions that wouldn’t be still validated by the server.

DataSPtr       write_document ();

In a nutshell, DataSPtr is a shared pointer of std::vector <ohm::archi::UByte> .

write_document_head

Writes a document and returns it into a shared pointer type object, with all the latent transactions that wouldn’t be still validated by the server.

DataSPtr       write_document_head ();

In a nutshell, DataSPtr is a shared pointer of std::vector <ohm::archi::UByte> .