Bonobo API Reference Manual
<<< Previous Page | Home | Up | Next Page >>>

# bonobo-storage

## Name

bonobo-storage -- Abstract implementation of the Bonobo::Storage interface

## Synopsis

    typedef     BonoboStorage;
    typedef     BonoboStorageClass;
    BonoboStorage* bonobo_storage_open          (const char *driver,
                                                 const char *path,
                                                 gint flags,
                                                 gint mode);
    BonoboStorage* bonobo_storage_open_full     (const char *driver,
                                                 const char *path,
                                                 gint flags,
                                                 gint mode,
                                                 CORBA_Environment *opt_ev);
    void        bonobo_storage_copy_to          (Bonobo_Storage src,
                                                 Bonobo_Storage dest,
                                                 CORBA_Environment *ev);
    void        bonobo_storage_write_class_id   (BonoboStorage *storage,
                                                 char *class_id);
    void        bonobo_stream_write_class_id    (BonoboStream *stream,
                                                 char *class_id);

## Description

The BonoboStorage C interface is extremely simple, this is since the CORBA client interface is where the action occurs. It is anticipated that relatively few people need to implement the Bonobo/Storage IDL interface.

The common entry point for BonoboStorage is that of opening a storage using the bonobo_storage_open function, perhaps by a container to use to persist a compound document:

Example 1. An example storage use case

    void
    container_save (SampleApp         *app,
                    const char        *filename,
                    CORBA_Environment *ev)
    {
    	BonoboStorage *storage;
    	Bonobo_Storage corba_storage;
    	GList *components;
    	int i;

    	storage = bonobo_storage_open (STORAGE_TYPE, filename,
    				       Bonobo_Storage_READ |
    				       Bonobo_Storage_WRITE |
    				       Bonobo_Storage_CREATE,
    				       0664);
    	g_return_if_fail (storage);

    	corba_storage = BONOBO_OBJREF (storage);

    	...
    	Serialize components to streams created in the storage
    	...

    	Bonobo_Storage_commit (corba_storage, ev);

    	CORBA_exception_free (ev);

    	bonobo_object_unref (BONOBO_OBJECT (storage));
    }

## Details

### BonoboStorage

    typedef struct {
            BonoboXObject object;

    	BonoboStoragePrivate *priv;
    } BonoboStorage;

### BonoboStorageClass

    typedef struct {
    	BonoboXObjectClass parent_class;

    	POA_Bonobo_Storage__epv epv;

    	/* virtual methods */
    	Bonobo_StorageInfo *(*get_info) (BonoboStorage *storage,
    					 const CORBA_char *path,
    					 const Bonobo_StorageInfoFields mask,
    					 CORBA_Environment *ev);
    	void          (*set_info)       (BonoboStorage *storage,
    					 const CORBA_char *path,
    					 const Bonobo_StorageInfo * info,
    					 const Bonobo_StorageInfoFields mask,
    					 CORBA_Environment *ev);
    	BonoboStream  *(*open_stream)   (BonoboStorage *storage,
    					 const CORBA_char *path,
    					 Bonobo_Storage_OpenMode,
    					 CORBA_Environment *ev);
    	BonoboStorage *(*open_storage)  (BonoboStorage *storage,
    					 const CORBA_char *path,
    					 Bonobo_Storage_OpenMode,
    					 CORBA_Environment *ev);
    	void         (*copy_to)         (BonoboStorage *storage,
    					 Bonobo_Storage target,
    					 CORBA_Environment *ev);
    	void         (*rename)          (BonoboStorage *storage,
    					 const CORBA_char *path_name,
    					 const CORBA_char *new_path_name,
    					 CORBA_Environment *ev);
    	void         (*commit)          (BonoboStorage *storage,
    					 CORBA_Environment *ev);
    	void         (*revert)          (BonoboStorage *storage,
    					 CORBA_Environment *ev);
    	Bonobo_Storage_DirectoryList *
    	             (*list_contents)   (BonoboStorage *storage,
    					 const CORBA_char *path,
    					 Bonobo_StorageInfoFields mask,
    					 CORBA_Environment *ev);
    	void         (*erase)           (BonoboStorage *storage,
                                             const CORBA_char *path,
                                             CORBA_Environment *ev);
    } BonoboStorageClass;

### bonobo_storage_open ()

    BonoboStorage* bonobo_storage_open          (const char *driver,
                                                 const char *path,
                                                 gint flags,
                                                 gint mode);

Opens or creates the file named at `path` with the stream driver `driver`.

`driver` is one of: "efs", "vfs" or "fs" for now, please use the macros for this though, see bonobo-stream.h eg. BONOBO_IO_DRIVER_FS

`driver` : | driver to use for opening.
`path` : | path where the base file resides
`flags` : | Bonobo Storage OpenMode
`mode` : | Unix open(2) mode
Returns : | a created BonoboStorage object.

### bonobo_storage_open_full ()

    BonoboStorage* bonobo_storage_open_full     (const char *driver,
                                                 const char *path,
                                                 gint flags,
                                                 gint mode,
                                                 CORBA_Environment *opt_ev);

`driver` : |
`path` : |
`flags` : |
`mode` : |
`opt_ev` : |
Returns : |

### bonobo_storage_copy_to ()

    void        bonobo_storage_copy_to          (Bonobo_Storage src,
                                                 Bonobo_Storage dest,
                                                 CORBA_Environment *ev);

Implements a pure CORBA method for copying one storage into another, this is used by several BonoboStorage implemetations where a fast case localy copy cannot work.

`src` : | the source storage
`dest` : | the destination storage
`ev` : | CORBA exception environment

### bonobo_storage_write_class_id ()

    void        bonobo_storage_write_class_id   (BonoboStorage *storage,
                                                 char *class_id);

`storage` : |
`class_id` : |

### bonobo_stream_write_class_id ()

    void        bonobo_stream_write_class_id    (BonoboStream *stream,
                                                 char *class_id);

`stream` : |
`class_id` : |

## See Also

BonoboPersist BonoboPersistStream

<<< Previous Page | Home | Up | Next Page >>>
Storage and Persistance | BonoboStream