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

# BonoboMonikerSimple

## Name

BonoboMonikerSimple -- A super easy to use moniker implementation wrapper

## Synopsis

    struct      BonoboMonikerSimple;
    Bonobo_Unknown (*BonoboMonikerSimpleResolveFn)
                                                (BonoboMoniker *moniker,
                                                 const Bonobo_ResolveOptions *options,
                                                 const CORBA_char *requested_interface,
                                                 CORBA_Environment *ev);
    BonoboMoniker* bonobo_moniker_simple_new    (const char *name,
                                                 BonoboMonikerSimpleResolveFn resolve_fn);
    BonoboMoniker* bonobo_moniker_simple_construct
                                                (BonoboMonikerSimple *moniker,
                                                 const char *name,
                                                 BonoboMonikerSimpleResolveFn resolve_fn);

## Object Hierarchy

      GtkObject
       +----BonoboObject
             +----BonoboXObject
                   +----BonoboMoniker
                         +----BonoboMonikerSimple

## Description

BonoboMonikerSimple makes writing monikers really extremely easy. To implement a moniker you only have to write 1 function. To register create the moniker object you have to use only 1 call. It can't get much simpler. If you want to use monikers instead of implementing them, you probably want to see bonobo-moniker-util instead.

Few people need to implement monikers, but if they do, this is how they should do it:

Example 1. A cut down file: moniker implementation

    Bonobo_Unknown
    bonobo_moniker_file_resolve (BonoboMoniker               *moniker,
    			     const Bonobo_ResolveOptions *options,
    			     const CORBA_char            *requested_interface,
    			     CORBA_Environment           *ev)
    {
    	const char    *fname = bonobo_moniker_get_name (moniker);
    	Bonobo_Unknown retval;

    	g_warning ("Fname 's'", fname);

    	if (!strcmp (requested_interface, "IDL:Bonobo/Stream:1.0")) {
    		BonoboStream *stream;

    		stream = bonobo_stream_open ("fs", fname,
    					     Bonobo_Storage_READ, 0664);

    		if (!stream) {
    			g_warning ("Failed to open stream 's'", fname);
    			CORBA_exception_set (ev, CORBA_USER_EXCEPTION,
    					     ex_Bonobo_Moniker_InterfaceNotFound, NULL);
    			return CORBA_OBJECT_NIL;
    		}

    		return CORBA_Object_duplicate (BONOBO_OBJREF (stream), ev);
    	}

    	return CORBA_OBJECT_NIL;
    }

After implementing the resolve function, you need to create the new moniker in your standard factory:

Example 2. Creating a new simple moniker

    static BonoboObject *
    bonobo_std_moniker_factory (BonoboGenericFactory *this,
    			    const char           *object_id,
    			    void                 *data)
    {
    	g_return_val_if_fail (object_id != NULL, NULL);

    	if (!strcmp (object_id, "OAFIID:Bonobo_Moniker_File"))

    		return BONOBO_OBJECT (bonobo_moniker_simple_new (
    			"file:", bonobo_moniker_file_resolve));
    	else
    		return NULL;
    }

## Details

### struct BonoboMonikerSimple

    struct BonoboMonikerSimple;

### BonoboMonikerSimpleResolveFn ()

    Bonobo_Unknown (*BonoboMonikerSimpleResolveFn)
                                                (BonoboMoniker *moniker,
                                                 const Bonobo_ResolveOptions *options,
                                                 const CORBA_char *requested_interface,
                                                 CORBA_Environment *ev);

`moniker` : |
`options` : |
`requested_interface` : |
`ev` : |
Returns : |

### bonobo_moniker_simple_new ()

    BonoboMoniker* bonobo_moniker_simple_new    (const char *name,
                                                 BonoboMonikerSimpleResolveFn resolve_fn);

Create a new instance of a simplified moniker.

`name` : | the display name for the moniker
`resolve_fn` : | a resolve function for the moniker
Returns : | the moniker object

### bonobo_moniker_simple_construct ()

    BonoboMoniker* bonobo_moniker_simple_construct
                                                (BonoboMonikerSimple *moniker,
                                                 const char *name,
                                                 BonoboMonikerSimpleResolveFn resolve_fn);

Constructs a simple moniker

`moniker` : | the moniker to construct
`name` : | the name of the moniker eg. 'file:'
`resolve_fn` : | the function used to resolve the moniker
Returns : | the constructed moniker or NULL on failure.

## See Also

BonoboMoniker, BonoboMonikerSimple, bonobo-moniker-util, BonoboMonikerExtender

<<< Previous Page | Home | Up | Next Page >>>
BonoboMoniker | BonoboMonikerExtender