DeeResourceManager

DeeResourceManager — Store and load DeeSerializables by name

Functions

DeeResourceManager * dee_resource_manager_get_default ()
GObject * dee_resource_manager_load ()
gboolean dee_resource_manager_store ()

Types and Values

Object Hierarchy


Includes

#include <dee.h>

Description

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.

Functions

dee_resource_manager_get_default ()

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]


dee_resource_manager_load ()

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.

Parameters

self

The resource manager to invoke

 

resource_name

The name of the resource to retrieve

 

error

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]


dee_resource_manager_store ()

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.

Parameters

self

The resource manager to invoke

 

resource

A DeeSerializable to store under resource_name .

[transfer none]

resource_name

The name to store the resource under. Will overwrite any existing resource with the same name

 

error

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.

Types and Values

struct DeeResourceManagerIface

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);
};