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

-- module HROOT.Class.Interface where

module HROOT.Hist.TH1K.Interface where


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

import HROOT.Hist.TH1K.RawType

import HROOT.Hist.TH1.Interface
import HROOT.Core.TArrayF.Interface
---- ============ ----



class (ITH1 a,ITArrayF a) => ITH1K a where

instance Existable TH1K where
  data Exist TH1K = forall a. (FPtr a, ITH1K a) => ETH1K a

upcastTH1K :: (FPtr a, ITH1K a) => a -> TH1K
upcastTH1K h = let fh = get_fptr h
                   fh2 :: ForeignPtr RawTH1K = castForeignPtr fh
               in cast_fptr_to_obj fh2

downcastTH1K :: (FPtr a, ITH1K a) => TH1K -> a 
downcastTH1K h = let fh = get_fptr h
                     fh2 = castForeignPtr fh
                 in cast_fptr_to_obj fh2