![]() |
![]() |
![]() |
Libmatecomponent Reference Manual | ![]() |
---|---|---|---|---|
Top | Description | Object Hierarchy |
MateComponentMonikerSimpleMateComponentMonikerSimple — A super easy to use moniker implementation wrapper |
MateComponentMonikerSimple; MateComponentMonikerSimpleClass; MateComponent_Unknown (*MateComponentMonikerSimpleResolveFn) (MateComponentMoniker *moniker
,const MateComponent_ResolveOptions *options
,const CORBA_char *requested_interface
,CORBA_Environment *ev
); MateComponentMoniker * matecomponent_moniker_simple_construct (MateComponentMonikerSimple *moniker
,const char *name
,GClosure *resolve_closure
); MateComponentMoniker * matecomponent_moniker_simple_new (const char *name
,MateComponentMonikerSimpleResolveFn resolve_fn
); MateComponentMoniker * matecomponent_moniker_simple_new_closure (const char *name
,GClosure *resolve_closure
);
GObject +----MateComponentObject +----MateComponentMoniker +----MateComponentMonikerSimple
MateComponentMonikerSimple 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 matecomponent-moniker-util instead.
Few people need to implement monikers, but if they do, this is how they should do it:
Example 15. A cut down file: moniker implementation
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
MateComponent_Unknown matecomponent_moniker_file_resolve (MateComponentMoniker *moniker, const MateComponent_ResolveOptions *options, const CORBA_char *requested_interface, CORBA_Environment *ev) { const char *fname = matecomponent_moniker_get_name (moniker); MateComponent_Unknown retval; g_warning ("Fname '%s'", fname); if (!strcmp (requested_interface, "IDL:MateComponent/Stream:1.0")) { MateComponentStream *stream; stream = matecomponent_stream_open ("fs", fname, MateComponent_Storage_READ, 0664); if (!stream) { g_warning ("Failed to open stream '%s'", fname); CORBA_exception_set (ev, CORBA_USER_EXCEPTION, ex_MateComponent_Moniker_InterfaceNotFound, NULL); return CORBA_OBJECT_NIL; } return CORBA_Object_duplicate (MATECOMPONENT_OBJREF (stream), ev); } return CORBA_OBJECT_NIL; } |
After implementing the resolve function, you need to create the new moniker
in your standard factory:
Example 16. Creating a new simple moniker
1 2 3 4 5 6 7 8 9 10 11 12 |
static MateComponentObject * matecomponent_std_moniker_factory (MateComponentGenericFactory *this, const char *object_id, void *data) { g_return_val_if_fail (object_id != NULL, NULL); if (!strcmp (object_id, "OAFIID:MateComponent_Moniker_File")) return MATECOMPONENT_OBJECT (matecomponent_moniker_simple_new ( "file:", matecomponent_moniker_file_resolve)); else return NULL; } |
typedef struct _MateComponentMonikerSimple MateComponentMonikerSimple;
A simplified MateComponentMoniker.
typedef struct { MateComponentMonikerClass parent_class; } MateComponentMonikerSimpleClass;
MateComponentMonikerSimple's class.
MateComponent_Unknown (*MateComponentMonikerSimpleResolveFn) (MateComponentMoniker *moniker
,const MateComponent_ResolveOptions *options
,const CORBA_char *requested_interface
,CORBA_Environment *ev
);
Type of callback function that implements a simple moniker resolution.
|
the moniker |
|
resolve options |
|
the requested interface (repoid string) |
|
CORBA environment, in case an exception needs to be raised |
Returns : |
a MateComponent_Unknown as the result of the resolution |
MateComponentMoniker * matecomponent_moniker_simple_construct (MateComponentMonikerSimple *moniker
,const char *name
,GClosure *resolve_closure
);
Constructs a simple moniker
|
the moniker to construct |
|
the name of the moniker eg. 'file:' |
|
the closure used to resolve the moniker |
Returns : |
the constructed moniker or NULL on failure. |
MateComponentMoniker * matecomponent_moniker_simple_new (const char *name
,MateComponentMonikerSimpleResolveFn resolve_fn
);
Create a new instance of a simplified moniker.
|
the display name for the moniker |
|
a resolve function for the moniker |
Returns : |
the moniker object |
MateComponentMoniker * matecomponent_moniker_simple_new_closure (const char *name
,GClosure *resolve_closure
);
Create a new instance of a simplified moniker.
Instead of the MateComponent_ResolveOptions struct, the closure takes its contents as two arguments: MATECOMPONENT_TYPE_RESOLVE_FLAG and G_TYPE_LONG.
|
the display name for the moniker |
|
a closure for the resolve process. |
Returns : |
the moniker object |
MateComponentMoniker, MateComponentMonikerSimple, matecomponent-moniker-util, MateComponentMonikerExtender