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

-- module HROOT.Class.Interface where

module HROOT.IO.TFile.Interface where


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

import HROOT.IO.TFile.RawType

import HROOT.IO.TDirectoryFile.Interface
---- ============ ----



class (ITDirectoryFile a) => ITFile a where

instance Existable TFile where
  data Exist TFile = forall a. (FPtr a, ITFile a) => ETFile a

upcastTFile :: (FPtr a, ITFile a) => a -> TFile
upcastTFile h = let fh = get_fptr h
                    fh2 :: ForeignPtr RawTFile = castForeignPtr fh
                in cast_fptr_to_obj fh2

downcastTFile :: (FPtr a, ITFile a) => TFile -> a 
downcastTFile h = let fh = get_fptr h
                      fh2 = castForeignPtr fh
                  in cast_fptr_to_obj fh2