1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
2 /* e-book-backend-factory.h
4 * Copyright (C) 2004 Novell, Inc.
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of version 2 of the GNU Lesser General Public
8 * License as published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this program; if not, write to the
17 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
20 * Author: Chris Toshok <toshok@ximian.com>
23 #ifndef _E_BOOK_BACKEND_FACTORY_H_
24 #define _E_BOOK_BACKEND_FACTORY_H_
26 #include <glib-object.h>
27 #include "e-book-backend.h"
31 #define E_TYPE_BOOK_BACKEND_FACTORY (e_book_backend_factory_get_type ())
32 #define E_BOOK_BACKEND_FACTORY(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), E_TYPE_BOOK_BACKEND_FACTORY, EBookBackendFactory))
33 #define E_BOOK_BACKEND_FACTORY_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), E_TYPE_BOOK_BACKEND_FACTORY, EBookBackendFactoryClass))
34 #define E_IS_BOOK_BACKEND_FACTORY(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), E_TYPE_BOOK_BACKEND_FACTORY))
35 #define E_IS_BOOK_BACKEND_FACTORY_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), E_TYPE_BOOK_BACKEND_FACTORY))
36 #define E_BOOK_BACKEND_FACTORY_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), E_TYPE_BOOK_BACKEND_FACTORY, EBookBackendFactoryClass))
38 typedef struct _EBookBackendFactoryPrivate EBookBackendFactoryPrivate;
41 GObject parent_object;
42 } EBookBackendFactory;
45 GObjectClass parent_class;
47 const char* (*get_protocol) (EBookBackendFactory *factory);
48 EBookBackend* (*new_backend) (EBookBackendFactory *factory);
49 } EBookBackendFactoryClass;
51 GType e_book_backend_factory_get_type (void);
53 const char* e_book_backend_factory_get_protocol (EBookBackendFactory *factory);
54 EBookBackend* e_book_backend_factory_new_backend (EBookBackendFactory *factory);
57 /* use this macro for simple, 1 factory modules */
58 #define E_BOOK_BACKEND_FACTORY_SIMPLE(p,t,f) \
60 EBookBackendFactory parent_object; \
61 } EBookBackend##t##Factory; \
64 EBookBackendFactoryClass parent_class; \
65 } EBookBackend##t##FactoryClass; \
68 _ ## p ##_factory_instance_init (EBookBackend## t ##Factory *factory) \
73 _ ## p ##_get_protocol (EBookBackendFactory *factory) \
78 static EBookBackend* \
79 _ ## p ##_new_backend (EBookBackendFactory *factory) \
85 _ ## p ##_factory_class_init (EBookBackend## t ##FactoryClass *klass) \
87 E_BOOK_BACKEND_FACTORY_CLASS (klass)->get_protocol = _ ## p ##_get_protocol; \
88 E_BOOK_BACKEND_FACTORY_CLASS (klass)->new_backend = _ ## p ##_new_backend; \
92 _ ## p ##_factory_get_type (GTypeModule *module) \
97 sizeof (EBookBackend##t##FactoryClass), \
98 NULL, /* base_class_init */ \
99 NULL, /* base_class_finalize */ \
100 (GClassInitFunc) _ ## p ##_factory_class_init, \
101 NULL, /* class_finalize */ \
102 NULL, /* class_data */ \
103 sizeof (EBookBackend##t##Factory), \
104 0, /* n_preallocs */ \
105 (GInstanceInitFunc) _ ## p ##_factory_instance_init \
108 type = g_type_module_register_type (module, \
109 E_TYPE_BOOK_BACKEND_FACTORY, \
110 "EBookBackend" #t "Factory", \
118 #endif /* _E_BOOK_BACKEND_FACTORY_H_ */