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

-- module HROOT.Class.Interface where

module HROOT.Hist.TH2S.Interface where


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

import HROOT.Hist.TH2S.RawType

import HROOT.Hist.TH2.Interface
import HROOT.Core.TArrayS.Interface
---- ============ ----



class (ITH2 a,ITArrayS a) => ITH2S a where

instance Existable TH2S where
  data Exist TH2S = forall a. (FPtr a, ITH2S a) => ETH2S a

upcastTH2S :: (FPtr a, ITH2S a) => a -> TH2S
upcastTH2S h = let fh = get_fptr h
                   fh2 :: ForeignPtr RawTH2S = castForeignPtr fh
               in cast_fptr_to_obj fh2

downcastTH2S :: (FPtr a, ITH2S a) => TH2S -> a 
downcastTH2S h = let fh = get_fptr h
                     fh2 = castForeignPtr fh
                 in cast_fptr_to_obj fh2