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

-- module HROOT.Class.Interface where

module HROOT.Core.TKey.Interface where


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

import HROOT.Core.TKey.RawType

import HROOT.Core.TNamed.Interface
---- ============ ----



class (ITNamed a) => ITKey a where

instance Existable TKey where
  data Exist TKey = forall a. (FPtr a, ITKey a) => ETKey a

upcastTKey :: (FPtr a, ITKey a) => a -> TKey
upcastTKey h = let fh = get_fptr h
                   fh2 :: ForeignPtr RawTKey = castForeignPtr fh
               in cast_fptr_to_obj fh2

downcastTKey :: (FPtr a, ITKey a) => TKey -> a 
downcastTKey h = let fh = get_fptr h
                     fh2 = castForeignPtr fh
                 in cast_fptr_to_obj fh2