2 * Copyright (C) 2008 Martin Willi
3 * Hochschule fuer Technik Rapperswil
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 * @defgroup database_factory database_factory
18 * @{ @ingroup database
21 #ifndef DATABASE_FACTORY_H_
22 #define DATABASE_FACTORY_H_
24 typedef struct database_factory_t database_factory_t
;
26 #include <database/database.h>
29 * Generic database construction function.
31 * @param uri implementation specific connection URI
33 typedef database_t
*(*database_constructor_t
)(char *uri
);
36 * Create instances of database connections using registered constructors.
38 struct database_factory_t
{
41 * Create a database connection instance.
43 * @param uri implementation specific connection URI
44 * @return database_t instance, NULL if not supported/failed
46 database_t
* (*create
)(database_factory_t
*this, char *uri
);
49 * Register a database constructor.
51 * @param create database constructor to register
53 void (*add_database
)(database_factory_t
*this, database_constructor_t create
);
56 * Unregister a previously registered database constructor.
58 * @param create database constructor to unregister
60 void (*remove_database
)(database_factory_t
*this, database_constructor_t create
);
63 * Destroy a database_factory instance.
65 void (*destroy
)(database_factory_t
*this);
69 * Create a database_factory instance.
71 database_factory_t
*database_factory_create();
73 #endif /* DATABASE_FACTORY_H_ @}*/