{- |
Copyright  : Will Thompson, Iñaki García Etxebarria and Jonas Platte
License    : LGPL-2.1
Maintainer : Iñaki García Etxebarria (garetxe@gmail.com)

Represents a git remote head.
-}

module GI.Ggit.Structs.RemoteHead
    ( 

-- * Exported types
    RemoteHead(..)                          ,
    noRemoteHead                            ,


 -- * Methods
-- ** getLocalOid #method:getLocalOid#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    RemoteHeadGetLocalOidMethodInfo         ,
#endif
    remoteHeadGetLocalOid                   ,


-- ** getName #method:getName#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    RemoteHeadGetNameMethodInfo             ,
#endif
    remoteHeadGetName                       ,


-- ** getOid #method:getOid#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    RemoteHeadGetOidMethodInfo              ,
#endif
    remoteHeadGetOid                        ,


-- ** isLocal #method:isLocal#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    RemoteHeadIsLocalMethodInfo             ,
#endif
    remoteHeadIsLocal                       ,


-- ** ref #method:ref#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    RemoteHeadRefMethodInfo                 ,
#endif
    remoteHeadRef                           ,


-- ** unref #method:unref#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    RemoteHeadUnrefMethodInfo               ,
#endif
    remoteHeadUnref                         ,




    ) where

import Data.GI.Base.ShortPrelude
import qualified Data.GI.Base.ShortPrelude as SP
import qualified Data.GI.Base.Overloading as O
import qualified Prelude as P

import qualified Data.GI.Base.Attributes as GI.Attributes
import qualified Data.GI.Base.ManagedPtr as B.ManagedPtr
import qualified Data.GI.Base.GError as B.GError
import qualified Data.GI.Base.GVariant as B.GVariant
import qualified Data.GI.Base.GParamSpec as B.GParamSpec
import qualified Data.GI.Base.CallStack as B.CallStack
import qualified Data.Text as T
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map
import qualified Foreign.Ptr as FP

import {-# SOURCE #-} qualified GI.Ggit.Structs.OId as Ggit.OId

newtype RemoteHead = RemoteHead (ManagedPtr RemoteHead)
foreign import ccall "ggit_remote_head_get_type" c_ggit_remote_head_get_type :: 
    IO GType

instance BoxedObject RemoteHead where
    boxedType _ = c_ggit_remote_head_get_type

noRemoteHead :: Maybe RemoteHead
noRemoteHead = Nothing


#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
instance O.HasAttributeList RemoteHead
type instance O.AttributeList RemoteHead = RemoteHeadAttributeList
type RemoteHeadAttributeList = ('[ ] :: [(Symbol, *)])
#endif

-- method RemoteHead::get_local_oid
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "remote_head", argType = TInterface (Name {namespace = "Ggit", name = "RemoteHead"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GgitRemoteHead.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Ggit", name = "OId"}))
-- throws : False
-- Skip return : False

foreign import ccall "ggit_remote_head_get_local_oid" ggit_remote_head_get_local_oid :: 
    Ptr RemoteHead ->                       -- remote_head : TInterface (Name {namespace = "Ggit", name = "RemoteHead"})
    IO (Ptr Ggit.OId.OId)

{- |
Get the local oid of the remote head.
-}
remoteHeadGetLocalOid ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    RemoteHead
    {- ^ /@remoteHead@/: a 'GI.Ggit.Structs.RemoteHead.RemoteHead'. -}
    -> m Ggit.OId.OId
    {- ^ __Returns:__ the local oid. -}
remoteHeadGetLocalOid remoteHead = liftIO $ do
    remoteHead' <- unsafeManagedPtrGetPtr remoteHead
    result <- ggit_remote_head_get_local_oid remoteHead'
    checkUnexpectedReturnNULL "remoteHeadGetLocalOid" result
    result' <- (newBoxed Ggit.OId.OId) result
    touchManagedPtr remoteHead
    return result'

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data RemoteHeadGetLocalOidMethodInfo
instance (signature ~ (m Ggit.OId.OId), MonadIO m) => O.MethodInfo RemoteHeadGetLocalOidMethodInfo RemoteHead signature where
    overloadedMethod _ = remoteHeadGetLocalOid

#endif

-- method RemoteHead::get_name
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "remote_head", argType = TInterface (Name {namespace = "Ggit", name = "RemoteHead"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GgitRemoteHead.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "ggit_remote_head_get_name" ggit_remote_head_get_name :: 
    Ptr RemoteHead ->                       -- remote_head : TInterface (Name {namespace = "Ggit", name = "RemoteHead"})
    IO CString

{- |
Get the remote head name.
-}
remoteHeadGetName ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    RemoteHead
    {- ^ /@remoteHead@/: a 'GI.Ggit.Structs.RemoteHead.RemoteHead'. -}
    -> m T.Text
    {- ^ __Returns:__ the remote head name. -}
remoteHeadGetName remoteHead = liftIO $ do
    remoteHead' <- unsafeManagedPtrGetPtr remoteHead
    result <- ggit_remote_head_get_name remoteHead'
    checkUnexpectedReturnNULL "remoteHeadGetName" result
    result' <- cstringToText result
    touchManagedPtr remoteHead
    return result'

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data RemoteHeadGetNameMethodInfo
instance (signature ~ (m T.Text), MonadIO m) => O.MethodInfo RemoteHeadGetNameMethodInfo RemoteHead signature where
    overloadedMethod _ = remoteHeadGetName

#endif

-- method RemoteHead::get_oid
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "remote_head", argType = TInterface (Name {namespace = "Ggit", name = "RemoteHead"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GgitRemoteHead.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Ggit", name = "OId"}))
-- throws : False
-- Skip return : False

foreign import ccall "ggit_remote_head_get_oid" ggit_remote_head_get_oid :: 
    Ptr RemoteHead ->                       -- remote_head : TInterface (Name {namespace = "Ggit", name = "RemoteHead"})
    IO (Ptr Ggit.OId.OId)

{- |
Get the remote oid of the remote head.
-}
remoteHeadGetOid ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    RemoteHead
    {- ^ /@remoteHead@/: a 'GI.Ggit.Structs.RemoteHead.RemoteHead'. -}
    -> m Ggit.OId.OId
    {- ^ __Returns:__ the remote oid. -}
remoteHeadGetOid remoteHead = liftIO $ do
    remoteHead' <- unsafeManagedPtrGetPtr remoteHead
    result <- ggit_remote_head_get_oid remoteHead'
    checkUnexpectedReturnNULL "remoteHeadGetOid" result
    result' <- (newBoxed Ggit.OId.OId) result
    touchManagedPtr remoteHead
    return result'

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data RemoteHeadGetOidMethodInfo
instance (signature ~ (m Ggit.OId.OId), MonadIO m) => O.MethodInfo RemoteHeadGetOidMethodInfo RemoteHead signature where
    overloadedMethod _ = remoteHeadGetOid

#endif

-- method RemoteHead::is_local
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "remote_head", argType = TInterface (Name {namespace = "Ggit", name = "RemoteHead"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GgitRemoteHead.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "ggit_remote_head_is_local" ggit_remote_head_is_local :: 
    Ptr RemoteHead ->                       -- remote_head : TInterface (Name {namespace = "Ggit", name = "RemoteHead"})
    IO CInt

{- |
Get whether the remote head is local.
-}
remoteHeadIsLocal ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    RemoteHead
    {- ^ /@remoteHead@/: a 'GI.Ggit.Structs.RemoteHead.RemoteHead'. -}
    -> m Bool
    {- ^ __Returns:__ whether the remote head is local. -}
remoteHeadIsLocal remoteHead = liftIO $ do
    remoteHead' <- unsafeManagedPtrGetPtr remoteHead
    result <- ggit_remote_head_is_local remoteHead'
    let result' = (/= 0) result
    touchManagedPtr remoteHead
    return result'

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data RemoteHeadIsLocalMethodInfo
instance (signature ~ (m Bool), MonadIO m) => O.MethodInfo RemoteHeadIsLocalMethodInfo RemoteHead signature where
    overloadedMethod _ = remoteHeadIsLocal

#endif

-- method RemoteHead::ref
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "remote_head", argType = TInterface (Name {namespace = "Ggit", name = "RemoteHead"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Ggit", name = "RemoteHead"}))
-- throws : False
-- Skip return : False

foreign import ccall "ggit_remote_head_ref" ggit_remote_head_ref :: 
    Ptr RemoteHead ->                       -- remote_head : TInterface (Name {namespace = "Ggit", name = "RemoteHead"})
    IO (Ptr RemoteHead)

{- |
/No description available in the introspection data./
-}
remoteHeadRef ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    RemoteHead
    -> m RemoteHead
remoteHeadRef remoteHead = liftIO $ do
    remoteHead' <- unsafeManagedPtrGetPtr remoteHead
    result <- ggit_remote_head_ref remoteHead'
    checkUnexpectedReturnNULL "remoteHeadRef" result
    result' <- (wrapBoxed RemoteHead) result
    touchManagedPtr remoteHead
    return result'

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data RemoteHeadRefMethodInfo
instance (signature ~ (m RemoteHead), MonadIO m) => O.MethodInfo RemoteHeadRefMethodInfo RemoteHead signature where
    overloadedMethod _ = remoteHeadRef

#endif

-- method RemoteHead::unref
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "remote_head", argType = TInterface (Name {namespace = "Ggit", name = "RemoteHead"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "ggit_remote_head_unref" ggit_remote_head_unref :: 
    Ptr RemoteHead ->                       -- remote_head : TInterface (Name {namespace = "Ggit", name = "RemoteHead"})
    IO ()

{- |
/No description available in the introspection data./
-}
remoteHeadUnref ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    RemoteHead
    -> m ()
remoteHeadUnref remoteHead = liftIO $ do
    remoteHead' <- unsafeManagedPtrGetPtr remoteHead
    ggit_remote_head_unref remoteHead'
    touchManagedPtr remoteHead
    return ()

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data RemoteHeadUnrefMethodInfo
instance (signature ~ (m ()), MonadIO m) => O.MethodInfo RemoteHeadUnrefMethodInfo RemoteHead signature where
    overloadedMethod _ = remoteHeadUnref

#endif

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
type family ResolveRemoteHeadMethod (t :: Symbol) (o :: *) :: * where
    ResolveRemoteHeadMethod "isLocal" o = RemoteHeadIsLocalMethodInfo
    ResolveRemoteHeadMethod "ref" o = RemoteHeadRefMethodInfo
    ResolveRemoteHeadMethod "unref" o = RemoteHeadUnrefMethodInfo
    ResolveRemoteHeadMethod "getLocalOid" o = RemoteHeadGetLocalOidMethodInfo
    ResolveRemoteHeadMethod "getName" o = RemoteHeadGetNameMethodInfo
    ResolveRemoteHeadMethod "getOid" o = RemoteHeadGetOidMethodInfo
    ResolveRemoteHeadMethod l o = O.MethodResolutionFailed l o

instance (info ~ ResolveRemoteHeadMethod t RemoteHead, O.MethodInfo info RemoteHead p) => O.IsLabelProxy t (RemoteHead -> p) where
    fromLabelProxy _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)

#if MIN_VERSION_base(4,9,0)
instance (info ~ ResolveRemoteHeadMethod t RemoteHead, O.MethodInfo info RemoteHead p) => O.IsLabel t (RemoteHead -> p) where
#if MIN_VERSION_base(4,10,0)
    fromLabel = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#else
    fromLabel _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#endif
#endif

#endif