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

-- module HROOT.Class.Interface where

module HROOT.Graf.TBRIK.Interface where


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

import HROOT.Graf.TBRIK.RawType

import HROOT.Graf.TShape.Interface
---- ============ ----



class (ITShape a) => ITBRIK a where

instance Existable TBRIK where
  data Exist TBRIK = forall a. (FPtr a, ITBRIK a) => ETBRIK a

upcastTBRIK :: (FPtr a, ITBRIK a) => a -> TBRIK
upcastTBRIK h = let fh = get_fptr h
                    fh2 :: ForeignPtr RawTBRIK = castForeignPtr fh
                in cast_fptr_to_obj fh2

downcastTBRIK :: (FPtr a, ITBRIK a) => TBRIK -> a 
downcastTBRIK h = let fh = get_fptr h
                      fh2 = castForeignPtr fh
                  in cast_fptr_to_obj fh2