![]() |
![]() |
![]() |
Dee Reference Manual | ![]() |
---|---|---|---|---|
Top | Description | Object Hierarchy | Implemented Interfaces | Properties |
DeeSharedModelDeeSharedModel — A DeeModel that can synchronize with other DeeSharedModel objects across D-Bus. |
#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
);
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.
typedef struct _DeeSharedModel DeeSharedModel;
All fields in the DeeSharedModel structure are private and should never be accessed directly
typedef struct _DeeSharedModelPrivate DeeSharedModelPrivate;
Ignore this structure.
typedef enum { DEE_SHARED_MODEL_ERROR_LEADER_INVALIDATED } DeeSharedModelError;
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.
|
A well known name to publish this model under. Models sharing this name will synchronize with each other |
Returns : |
a new DeeSharedModel. [transfer full] |
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.
|
A well known name to publish this model under. Models sharing this name will synchronize with each other. [transfer none] |
|
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] |
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.
|
The model to get the name for |
Returns : |
The name of the swarm this model synchrnonizes with |
DeePeer* dee_shared_model_get_peer (DeeSharedModel *self
);
Convenience function for accessing the "peer" property
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.
|
The model to inspect |
Returns : |
The value of dee_peer_is_swarm_leader() for the DeePeer used by
this shared model
|
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.
|
The model to inspect |
Returns : |
The value of the :synchronized property |
"peer"
property"peer" DeePeer* : Read / Write / Construct Only
The peer object that monitors the swarm.
"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