{-# LANGUAGE ForeignFunctionInterface, TypeFamilies, MultiParamTypeClasses, 
             FlexibleInstances, TypeSynonymInstances, 
             EmptyDataDecls, ExistentialQuantification, ScopedTypeVariables #-}

-- module HROOT.Class.Interface where

module HROOT.Class.TDirectory.Interface where


import Data.Word
import Foreign.ForeignPtr
import HROOT.TypeCast

import HROOT.Class.TDirectory.RawType
import HROOT.Class.TObject.RawType
import HROOT.Class.TObject.Interface
import HROOT.Class.TKey.Interface
import HROOT.Class.TNamed.Interface


class (ITNamed a) => ITDirectory a where

    append :: (ITObject c0, FPtr c0) => a -> c0 -> Int -> IO () 

    addD :: (ITObject c0, FPtr c0) => a -> c0 -> Int -> IO () 

    appendKey :: (ITKey c0, FPtr c0) => a -> c0 -> IO Int 

    close :: a -> String -> IO () 

    get :: a -> String -> IO TObject 

instance Existable TDirectory where
  data Exist TDirectory = forall a. (FPtr a, ITDirectory a) => ETDirectory a

upcastTDirectory :: (FPtr a, ITDirectory a) => a -> TDirectory
upcastTDirectory h = let fh = get_fptr h
                         fh2 :: ForeignPtr RawTDirectory = castForeignPtr fh
                     in cast_fptr_to_obj fh2