/*
** SellaNMS
** $Id: storage.h,v 1.10 2005/11/26 06:48:45 sella Exp $
** Copyright (c) 2001-2005 Digital Genesis Software, LLC. All Rights Reserved.
** Released under the GPL Version 2 License.
** http://www.digitalgenesis.com
*/

#ifndef __DGS_LIBS_STORAGE_H
#define __DGS_LIBS_STORAGE_H

#ifdef HAVE_CONFIG_H
	#include "config.h"
#endif

#include "defaults.h"
#include "configuration/confignode.h"
#include "storage/storagedata.h"
#include "connection_pool.h"
#include <dbi/dbi.h>
#include <pthread.h>
#include <stl/string>
#include <stl/slist>

class Storage {
	public:
		Storage();
		Storage(Storage const &);
		~Storage();

		RESULT setConfig(ConfigNode &config);
		RESULT query(StorageData &data, const char *sql);
		RESULT queryf(StorageData &data, const char *sql, ...);
		RESULT getDbList(slist<string> &db_list, const char* pattern = NULL);
		RESULT getTableList(slist<string> &table_list, const char* db, const char* pattern = NULL);
		bool isConfigured();

		void check();
		void setDebug(bool debug = true);

	protected:
		void clear();

	private:
		void printError(dbi_conn connection);

		ConfigNode config;
		bool debug;
		unsigned int queryCount;

		conn_pool_t* conn;
};

#endif

/*
** Local Variables:
** c-basic-offset: 3
** tab-width: 3
** End:
** vim600: fdm=marker
** vim: noet ts=3 sw=3
*/
