![]() |
![]() |
![]() |
Dee Reference Manual | ![]() |
---|---|---|---|---|
Top | Description |
#include <dee.h> struct DeeResourceManagerIface; DeeResourceManager * dee_resource_manager_get_default (void
); GObject * dee_resource_manager_load (DeeResourceManager *self
,const gchar *resource_name
,GError **error
); gboolean dee_resource_manager_store (DeeResourceManager *self
,DeeSerializable *resource
,const gchar *resource_name
,GError **error
);
The DeeResourceManager API provides a simple API for storing and loading DeeSerializables from some persistent storage. The resources are stored in a flat structure identified by names that should be chosen similarly to DBus names. That is reverse domain names ala net.launchpad.Example.MyData.
struct DeeResourceManagerIface { GTypeInterface g_iface; gboolean (*store) (DeeResourceManager *self, DeeSerializable *resource, const gchar *resource_name, GError **error); GObject* (*load) (DeeResourceManager *self, const gchar *resource_name, GError **error); };
DeeResourceManager * dee_resource_manager_get_default (void
);
Get a pointer to the platform default DeeResourceManager.
Returns : |
The default resource manager for the platform. Do not unreference. If you need to keep the instance around you must manually reference it. [transfer none] |
GObject * dee_resource_manager_load (DeeResourceManager *self
,const gchar *resource_name
,GError **error
);
Load a resource from persistent storage. The loaded resource will be of the same GType as when it was stored (provided that the same serialization and parse functions are registered).
In case of an error the error will be in the GFileError domain. Specifically
if there is no resource with the name resource_name
the error code will
be G_FILE_ERROR_NOENT.
Important note: This call may do blocking IO. The resource manager must guarantee that this call is reasonably fast, like writing the externalized resource to a file, but not blocking IO over a network socket.
|
The resource manager to invoke |
|
The name of the resource to retrieve |
|
A return location for a GError pointer. NULL to ignore errors |
Returns : |
A newly allocated GObject in case of success
and NULL otherwise. In case of a runtime error the error
pointer will be set. [transfer full]
|
gboolean dee_resource_manager_store (DeeResourceManager *self
,DeeSerializable *resource
,const gchar *resource_name
,GError **error
);
Store a resource under a given name. The resource manager must guarantee
that the stored data survives system reboots and that you can recreate a
copy of resource
by calling dee_resource_manager_load()
using the
same resource_name
.
Important note: This call may do blocking IO. The resource manager must guarantee that this call is reasonably fast, like writing the externalized resource to a file, but not blocking IO over a network socket.
|
The resource manager to invoke |
|
A DeeSerializable to store under resource_name . [transfer none]
|
|
The name to store the resource under. Will overwrite any existing resource with the same name |
|
A return location for a GError pointer. NULL to ignore errors |
Returns : |
TRUE on success and FALSE otherwise. In case of a runtime
error the error pointer will point to a GError in the
DeeResourceError domain. |