DeeSharedModel

DeeSharedModel — A DeeModel that can synchronize with other DeeSharedModel objects across D-Bus.

Synopsis

#include <dee.h>

                    DeeSharedModel;
                    DeeSharedModelClass;
                    DeeSharedModelPrivate;
#define             DEE_SHARED_MODEL_DBUS_IFACE
enum                DeeSharedModelError;
DeeModel*           dee_shared_model_new                (const gchar *name);
DeeModel*           dee_shared_model_new_with_back_end  (const gchar *name,
                                                         DeeModel *back_end);
const gchar*        dee_shared_model_get_swarm_name     (DeeSharedModel *self);
DeePeer*            dee_shared_model_get_peer           (DeeSharedModel *self);
gboolean            dee_shared_model_is_leader          (DeeSharedModel *self);
gboolean            dee_shared_model_is_synchronized    (DeeSharedModel *self);

Object Hierarchy

  GObject
   +----DeeVersionedModel
         +----DeeProxyModel
               +----DeeSharedModel

Implemented Interfaces

DeeSharedModel implements DeeModel.

Properties

  "peer"                     DeePeer*              : Read / Write / Construct Only
  "synchronized"             gboolean              : Read

Description

DeeSharedModel is created with a name (usually namespaced and unique to your program(s)) which is used to locate other DeeSharedModels created with the same name through D-Bus, and will keep synchronized with them.

This allows to you build MVC programs with a sane model API, but have the controller (or multiple views) in a separate process.

Before you modify the contents of the shared model it is important that you wait for the model to synchronize with its peers. The normal way to do this is to wait for the "notify::synchronized" signal.

Details

DeeSharedModel

typedef struct _DeeSharedModel DeeSharedModel;

All fields in the DeeSharedModel structure are private and should never be accessed directly


DeeSharedModelClass

typedef struct {
} DeeSharedModelClass;


DeeSharedModelPrivate

typedef struct _DeeSharedModelPrivate DeeSharedModelPrivate;

Ignore this structure.


DEE_SHARED_MODEL_DBUS_IFACE

#define DEE_SHARED_MODEL_DBUS_IFACE "com.canonical.Dee.Model"


enum DeeSharedModelError

typedef enum
{
  DEE_SHARED_MODEL_ERROR_LEADER_INVALIDATED
} DeeSharedModelError;


dee_shared_model_new ()

DeeModel*           dee_shared_model_new                (const gchar *name);

Create a new empty shared model without any column schema associated. You should immediately set the model schema after creating the model.

A shared model created with this constructor will store row data in a suitably picked memory backed model.

name :

A well known name to publish this model under. Models sharing this name will synchronize with each other

Returns :

a new DeeSharedModel. [transfer full]

dee_shared_model_new_with_back_end ()

DeeModel*           dee_shared_model_new_with_back_end  (const gchar *name,
                                                         DeeModel *back_end);

Create a new shared model storing all data in back_end.

In order to start synchronizing the new model with peer models you must call dee_shared_model_connect() on it.

name :

A well known name to publish this model under. Models sharing this name will synchronize with each other. [transfer none]

back_end :

The DeeModel that will actually store the model data. Ownership of the ref to back_end is transfered to the shared model. [transfer full]

Returns :

a new DeeSharedModel. [transfer full]

dee_shared_model_get_swarm_name ()

const gchar*        dee_shared_model_get_swarm_name     (DeeSharedModel *self);

Convenience function for accessing the "swarm-name" property of the DeePeer defined in the "peer" property.

self :

The model to get the name for

Returns :

The name of the swarm this model synchrnonizes with

dee_shared_model_get_peer ()

DeePeer*            dee_shared_model_get_peer           (DeeSharedModel *self);

Convenience function for accessing the "peer" property

self :

The model to get the DeePeer for

Returns :

The DeePeer used to interact with the peer models. [transfer none]

dee_shared_model_is_leader ()

gboolean            dee_shared_model_is_leader          (DeeSharedModel *self);

Check if the model is the swarm leader. This is a convenience function for accessing the "peer" property and checking if it's the swarm leader.

self :

The model to inspect

Returns :

The value of dee_peer_is_swarm_leader() for the DeePeer used by this shared model

dee_shared_model_is_synchronized ()

gboolean            dee_shared_model_is_synchronized    (DeeSharedModel *self);

Check if the model is synchronized with its peers. Before modifying a shared model in any way (except dee_model_set_schema()) you should wait for it to become synchronized. This is normally done by waiting for the "notify::synchronized" signal.

This method is purely a convenience function for accessing the "synchronized" property.

self :

The model to inspect

Returns :

The value of the :synchronized property

Property Details

The "peer" property

  "peer"                     DeePeer*              : Read / Write / Construct Only

The peer object that monitors the swarm.


The "synchronized" property

  "synchronized"             gboolean              : Read

Boolean property defining whether or not the model has synchronized with its peers (if any) yet.

You should not modify a DeeSharedModel that is not synchronized. Before modifying the model in any way (except calling dee_model_set_schema()) you should wait for it to become synchronized.

Default value: FALSE