equal
deleted
inserted
replaced
1 #ifndef SERVICE_INTERNAL_H |
|
2 #define SERVICE_INTERNAL_H |
|
3 |
|
4 /** |
|
5 * @file |
|
6 * |
|
7 * Internal interface for implementations of service_t |
|
8 */ |
|
9 #include "service.h" |
|
10 #include "transport.h" |
|
11 #include "object.h" |
|
12 |
|
13 /** |
|
14 * The object_type of service_type |
|
15 */ |
|
16 extern const struct object_type service_type_type; |
|
17 |
|
18 /** |
|
19 * Type definition with method table |
|
20 */ |
|
21 struct service_type { |
|
22 struct object_type base_type; |
|
23 |
|
24 /** Method table */ |
|
25 struct service_methods { |
|
26 /** |
|
27 * Release internal state, but not the service_t itself |
|
28 */ |
|
29 void (*deinit) (service_t *service); |
|
30 } methods; |
|
31 }; |
|
32 |
|
33 /** |
|
34 * Base service_t state |
|
35 */ |
|
36 struct service { |
|
37 struct object base_obj; |
|
38 |
|
39 /** User info */ |
|
40 struct service_info info; |
|
41 }; |
|
42 |
|
43 /** |
|
44 * Initialize a service by binding it to a specific type, with the given user info for this service, and for spawned transports. |
|
45 */ |
|
46 void service_init (service_t *service, const struct service_type *type, const struct service_info *info); |
|
47 |
|
48 /** |
|
49 * Used to up-cast a generic service_t pointer to an implementation of the given service_type (or subtype). |
|
50 * |
|
51 * It is a bug to call this with a service of a different type. |
|
52 */ |
|
53 void* service_check (service_t *service, const struct service_type *type); |
|
54 |
|
55 /** |
|
56 * The service failed, call the user callback |
|
57 */ |
|
58 void service_error (service_t *service, const error_t *err); |
|
59 |
|
60 #endif /* SERVICE_INTERNAL_H */ |
|