Bonobo API Reference Manual | |||
---|---|---|---|
<<< Previous Page | Home | Up |
typedef |
BonoboObject is the base object in Bonobo for wrapping CORBA servers
as Gtk+ objects. HOWEVER, since it's use is complicated, it is left
in bonobo for the benefit of Nautilus' binary compatibility. It is
strongly recommended that
Again if you are looking to implement a CORBA interface you want to
see
The Bonobo::Unknown interface (wrapped by BonoboObject) is the foundation for the component system: it provides life cycle management for objects as well as service discovery.
The Bonobo interfaces are all based on the Bonobo::Unknown interface. This interface is very simple and provides two basic services: object lifetime management and object functionality-discovery. This interface only contains three methods, here it is:
module Bonobo { interface Unknown { void void |
The
The lifetime management is based on reference counting: when a component is initially launched, it starts life with a reference count of one. This reference is held by the component invoker. Each time a reference is kept to this object (say, you store a copy of the object in an array), the reference count is incremented. Every time a reference goes out of scope, the reference count needs to be decremented. When the reference count reaches zero, the component knows that there are no outstanding references to it, and it is safe to shutdown. At this point, the component shuts down.
It is possible to ask an object which implements the Bonobo::Unknown interface if it supports other CORBA interfaces. For example, it would be possible to ask an object whether it supports the "IDL:Bonobo/EmbeddablePrint:1.0" interface to find out if it is possible to print its contents. If the return value from invoking the query_interface method on the interface is CORBA_OBJECT_NIL, then we know that the requested interface is not supported. Otherwise, we can invoke IDL:Bonobo/EmbeddablePrint:1.0 methods on the returned CORBA Object.
Clients of the query_interface method use it to discover dynamically if a component supports a given interface. Sometimes the client code would require a specific interface to exist, but many times it is possible to operate in a "downgraded" mode. You should design your code to be able to cope with the lack of interfaces in objects. This will allow your program to deal with more components, and this also allows components to work in more situations.
For example, a help browser can load an HTML renderer component and ask this component which sort of features are supported by it:
stop_animations (BrowserHTML html) { BrowserControl control control = html->query_interface ("IDL:Browser/Control:1.0"); if (control) control-> |
The return value of the query_interface invocation contains a
reference to a CORBA object that is derived from the
Bonobo::Unknown interface or
CORBA_OBJECT_NIL if the interface is not supported by the
object. And this interface would have been already
BonoboObject implements the Bonobo::Unknown interface and exports the implementations of the methods in this class to simplify creating new objects that inherit from Bonobo::Unknown. This base object provides default implementations for the ref, unref and query_interface methods.
Other implementations reuse this implementation by listing on their VEPV tables the bonobo_object_epv entry point vector.
The Bonobo::Unknown interface is inspired by the Microsoft COM IUnknown interface but it has been translated into the CORBA world.
typedef struct { POA_Bonobo_Unknown servant_placeholder; gpointer bonobo_object; } BonoboObjectServant; |
This structure defines the type for BonoboObject-based CORBA servants.
If you decide not to use this scheme for fetching your per-servant
information, but still want to inherit from a
typedef struct { GtkObject base; Bonobo_Unknown corba_objref; gpointer servant; BonoboObjectPrivate *priv; } BonoboObject; |
typedef struct { GtkObjectClass parent_class; /* * signals. */ void (*query_interface) (BonoboObject *object, const char *repo_id, CORBA_Object *retval); void (*system_exception)(BonoboObject *object, CORBA_Object cobject, CORBA_Environment *ev); gpointer expansion; } BonoboObjectClass; |
|
Initializes the provided BonoboObject object. This method is usually invoked from the construct method for other Gtk-based CORBA wrappers that derive from the Bonobo::Unknown interface