src/lib/service_internal.h
branchnew-lib-errors
changeset 219 cefec18b8268
parent 175 a816950a6548
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/lib/service_internal.h	Thu May 28 01:17:36 2009 +0300
@@ -0,0 +1,60 @@
+#ifndef SERVICE_INTERNAL_H
+#define SERVICE_INTERNAL_H
+
+/**
+ * @file
+ *
+ * Internal interface for implementations of service_t
+ */
+#include "service.h"
+#include "transport.h"
+#include "object.h"
+
+/**
+ * The object_type of service_type
+ */
+extern const struct object_type service_type_type;
+
+/**
+ * Type definition with method table
+ */
+struct service_type {
+    struct object_type base_type;
+    
+    /** Method table */
+    struct service_methods {
+        /**
+         * Release internal state, but not the service_t itself
+         */
+        void (*deinit) (service_t *service);
+    } methods;
+};
+
+/**
+ * Base service_t state
+ */
+struct service {
+    struct object base_obj;
+
+    /** User info */
+    struct service_info info;
+};
+
+/**
+ * Initialize a service by binding it to a specific type, with the given user info for this service, and for spawned transports.
+ */
+void service_init (service_t *service, const struct service_type *type, const struct service_info *info);
+
+/**
+ * Used to up-cast a generic service_t pointer to an implementation of the given service_type (or subtype).
+ *
+ * It is a bug to call this with a service of a different type.
+ */
+void* service_check (service_t *service, const struct service_type *type);
+
+/**
+ * The service failed, call the user callback
+ */
+void service_error (service_t *service, const error_t *err);
+
+#endif /* SERVICE_INTERNAL_H */