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

-- module HROOT.Class.Interface where

module HROOT.Hist.TH3.Interface where


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

import HROOT.Hist.TH3.RawType
import HROOT.Hist.TH1D.RawType
import HROOT.Hist.TH1.RawType
import HROOT.Hist.TH1.Interface
import HROOT.Core.TAtt3D.Interface
---- ============ ----
import {-# SOURCE #-} HROOT.Hist.TF1.Interface


class (ITH1 a,ITAtt3D a) => ITH3 a where

    fill3 :: a -> CDouble -> CDouble -> CDouble -> IO CInt 

    fill3w :: a -> CDouble -> CDouble -> CDouble -> CDouble -> IO CInt 

    fitSlicesZ :: (ITF1 c0, FPtr c0) => a -> c0 -> CInt -> CInt -> CInt -> CInt -> CInt -> CString -> IO () 

    getCorrelationFactor3 :: a -> CInt -> CInt -> IO CDouble 

    getCovariance3 :: a -> CInt -> CInt -> IO CDouble 

    rebinX3 :: a -> CInt -> CString -> IO TH3 

    rebinY3 :: a -> CInt -> CString -> IO TH3 

    rebinZ3 :: a -> CInt -> CString -> IO TH3 

    rebin3D :: a -> CInt -> CInt -> CInt -> CString -> IO TH3 

instance Existable TH3 where
  data Exist TH3 = forall a. (FPtr a, ITH3 a) => ETH3 a

upcastTH3 :: (FPtr a, ITH3 a) => a -> TH3
upcastTH3 h = let fh = get_fptr h
                  fh2 :: ForeignPtr RawTH3 = castForeignPtr fh
              in cast_fptr_to_obj fh2

downcastTH3 :: (FPtr a, ITH3 a) => TH3 -> a 
downcastTH3 h = let fh = get_fptr h
                    fh2 = castForeignPtr fh
                in cast_fptr_to_obj fh2