{-- TerraHS - Interface between TerraLib and Haskell

    (c) Sergio Costa (INPE) - Setembro, 2005

	This program is free software; you can redistribute it 
    and/or modify it under the terms of the GNU General 
    Public License 2.1 as published by the Free Software Foundation
    (http://www.opensource.org/licenses/gpl-license.php)
--}

-- | Module for handling a databases connection
module TerraHS.Algebras.DB.Databases
	(
		-- * The @Connection@ class
		Connection (..),
		 
		-- * The @Databases@ class
		Databases (..)
	)
	where


import qualified Foreign.Ptr (Ptr)

class Connection c where
	-- | open a connection to a database
	open :: c -> IO (Foreign.Ptr.Ptr c) 				-- foreign connection (ex: TeDatabase)
	-- | close a opened connection
	close :: (Foreign.Ptr.Ptr c) -> Prelude.IO ()   		-- foreign connection (ex: TeDatabase)
	
	
class (Connection c) => Databases a c p where
	-- | load a object list from database
	retrieve :: (Foreign.Ptr.Ptr c) -> p -> IO a  				-- have side-effects
	-- | save a object list "a"  to database "Foreign.Ptr.Ptr c"
	store :: (Foreign.Ptr.Ptr c) -> p -> a -> IO Bool			-- have side-effects