Helper class to manage connection services (binds, matches and replies). More...
Related Functions | |
(Note that these are not member functions.) | |
| void | adbus_state_bind (adbus_State *s, adbus_Connection *c, const adbus_Bind *b) |
| Adds a binding to the supplied connection. | |
| void | adbus_state_addmatch (adbus_State *s, adbus_Connection *c, const adbus_Match *m) |
| Adds a match to the supplied connection. | |
| void | adbus_state_addreply (adbus_State *s, adbus_Connection *c, const adbus_Reply *r) |
| Adds a reply to the supplied connection. | |
| void | adbus_state_reset (adbus_State *s) |
| Resets the state, removing all services. | |
| void | adbus_state_free (adbus_State *s) |
| Frees the state, removing all services. | |
Helper class to manage connection services (binds, matches and replies).
adbus_State provides two benefits over using the connection services directly:
The general idea is to keep an adbus_State associated with any callback data (ie the local object, data structure, etc). Thus when the local object gets destroyed it simply needs to reset or free the state and all remaining callbacks are cleared out.
Some points to note:
For example:
struct Foo { adbus_State* state; }; struct Foo* CreateFoo() { struct Foo* f = (struct Foo*) calloc(sizeof(struct Foo), 1); f->state = adbus_state_new(); return f; } void DeleteFoo(struct Foo* f) { if (f) { adbus_state_free(f->state); free(f); } } static int SomeCallback(adbus_CbData* d) { struct Foo* f = (struct Foo*) d->user1; // Do something return 0; } void AddMatch(struct Foo* f, adbus_Connection* c) { adbus_Match m; adbus_match_init(&m); m.sender = "com.example.ExampleService"; m.path = "/"; m.member = "ExampleSignal"; m.callback = &SomeCallback; m.cuser = f; adbus_state_addmatch(f->state, c, &m); }
| void adbus_state_addmatch | ( | adbus_State * | s, | |
| adbus_Connection * | c, | |||
| const adbus_Match * | m | |||
| ) | [related] |
Adds a match to the supplied connection.
| void adbus_state_addreply | ( | adbus_State * | s, | |
| adbus_Connection * | c, | |||
| const adbus_Reply * | r | |||
| ) | [related] |
Adds a reply to the supplied connection.
| void adbus_state_bind | ( | adbus_State * | s, | |
| adbus_Connection * | c, | |||
| const adbus_Bind * | b | |||
| ) | [related] |
Adds a binding to the supplied connection.
| void adbus_state_reset | ( | adbus_State * | s | ) | [related] |
Resets the state, removing all services.
This will not free the state, so it is ready for reuse.
1.6.1