adbus_Bind Struct Reference

Data structure used to bind interfaces to a particular path. More...

Data Fields

const char * path
 Path to bind the interface to.
int pathSize
 Length of adbus_Bind::path or -1 if null terminated (default).
adbus_Interfaceinterface
 Interface to bind.
void * cuser2
 User pointer available as adbus_CbData::user2 in all the method and property callbacks.
adbus_ProxyMsgCallback proxy
 Callback to a proxy function called to proxy method and property sets/gets to the correct thread.
void * puser
 User data for adbus_Bind::proxy.
adbus_Callback release [2]
 Release callbacks called when the interface is unbound from this path.
void * ruser [2]
 User data for adbus_Bind::release.
adbus_ProxyCallback relproxy
 Proxy function for the release callbacks.
void * relpuser

Related Functions

(Note that these are not member functions.)



void adbus_bind_init (adbus_Bind *b)
 Initialises an adbus_Bind structure.

Detailed Description

Data structure used to bind interfaces to a particular path.

Note:
An adbus_Bind structure should always be initialised using adbus_bind_init().
The proxy and relproxy fields should almost always be initialised using adbus_conn_getproxy().

Client code registers for paths by:

  1. Creating an interface (see adbus_Interface). This registers all of the methods, properties, and signals on that interface and all of the callbacks for those. This is equivalent to defining an abstract base class or interface.
  2. The interface is then bound to a path using adbus_conn_bind(). The bind details what path to bind to and also binds in a user pointer so that the method callbacks can distinguish which object is being called.

For example:

  int ExampleMethod(adbus_CbData* d)
  {
      Object* o = (Object*) d->user2;
      o->ExampleMethod();
      return 0;
  }

  adbus_Interface* CreateInterface()
  {
      adbus_Interface* i = adbus_iface_new("com.example.Interface", -1);
      adbus_Member* m = adbus_iface_addmethod(i, "Example", -1);
      adbus_mbr_setmethod(m, &ExampleMethod, NULL);
      return i;
  }

  void Bind(adbus_Connection* c, Object* o, const char* path)
  {
      adbus_Interface* interface = CreateInterface();

      adbus_Bind b;
      adbus_bind_init(&b);
      b.path      = path;
      b.interface = interface;
      b.cuser2    = o;

      adbus_state_bind(o->state, c, &b);

      adbus_iface_free(interface);
  }
Note:
If writing C code directly, it's strongly suggested to use adbus_state_bind() since it vastly simplifies the management of unbinding and performs all of the thread jumping required in multithreaded applications.
See also:
adbus_Connection, adbus_conn_bind(), adbus_state_bind(), adbus_Interface, adbus_CbData

Field Documentation

User pointer available as adbus_CbData::user2 in all the method and property callbacks.

This user data can be freed on unbind by setting adbus_Bind::release and adbus_Bind::ruser.

Interface to bind.

The interface will be internally ref'd via adbus_iface_ref() after the call to adbus_conn_bind() or adbus_state_bind() so the calling code can "free" the interface if it wants to.

Callback to a proxy function called to proxy method and property sets/gets to the correct thread.

If this value is non-zero the proxy will be used to proxy all calls for this bind. In general it should be set be defaulted using adbus_conn_getproxy().

Proxy function for the release callbacks.

In general this should be defaulted using adbus_conn_getproxy().


The documentation for this struct was generated from the following files:
 All Data Structures Files Functions Variables Friends Defines

Generated on Mon Mar 22 00:10:02 2010 for adbus by  doxygen 1.6.1