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

-- module HROOT.Class.Interface where

module HROOT.Core.TDirectory.Interface where


import Data.Word
import Foreign.C
import Foreign.Ptr
import Foreign.ForeignPtr
import FFICXX.Runtime.Cast

import HROOT.Core.TDirectory.RawType
import HROOT.Core.TObject.RawType
import HROOT.Core.TNamed.Interface
---- ============ ----
import {-# SOURCE #-} HROOT.Core.TObject.Interface
import {-# SOURCE #-} HROOT.Core.TKey.Interface


class (ITNamed a) => ITDirectory a where

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

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

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

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

    get :: a -> CString -> IO TObject 

    cd_TDirectory :: a -> CString -> IO CInt 

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

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