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

-- module HROOT.Class.Interface where

module HROOT.Core.TROOT.Interface where


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

import HROOT.Core.TROOT.RawType
import HROOT.Core.TGlobal.RawType
import HROOT.Core.TDirectory.Interface
---- ============ ----



class (ITDirectory a) => ITROOT a where

instance Existable TROOT where
  data Exist TROOT = forall a. (FPtr a, ITROOT a) => ETROOT a

upcastTROOT :: (FPtr a, ITROOT a) => a -> TROOT
upcastTROOT h = let fh = get_fptr h
                    fh2 :: ForeignPtr RawTROOT = castForeignPtr fh
                in cast_fptr_to_obj fh2

downcastTROOT :: (FPtr a, ITROOT a) => TROOT -> a 
downcastTROOT h = let fh = get_fptr h
                      fh2 = castForeignPtr fh
                  in cast_fptr_to_obj fh2