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