{- |
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 push options.
-}

module GI.Ggit.Objects.PushOptions
    ( 

-- * Exported types
    PushOptions(..)                         ,
    IsPushOptions                           ,
    toPushOptions                           ,
    noPushOptions                           ,


 -- * Methods
-- ** getParallelism #method:getParallelism#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    PushOptionsGetParallelismMethodInfo     ,
#endif
    pushOptionsGetParallelism               ,


-- ** new #method:new#
    pushOptionsNew                          ,


-- ** setParallelism #method:setParallelism#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    PushOptionsSetParallelismMethodInfo     ,
#endif
    pushOptionsSetParallelism               ,




 -- * Properties
-- ** parallelism #attr:parallelism#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    PushOptionsParallelismPropertyInfo      ,
#endif
    constructPushOptionsParallelism         ,
    getPushOptionsParallelism               ,
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    pushOptionsParallelism                  ,
#endif
    setPushOptionsParallelism               ,




    ) 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 qualified GI.GObject.Objects.Object as GObject.Object

newtype PushOptions = PushOptions (ManagedPtr PushOptions)
foreign import ccall "ggit_push_options_get_type"
    c_ggit_push_options_get_type :: IO GType

instance GObject PushOptions where
    gobjectType _ = c_ggit_push_options_get_type
    

class GObject o => IsPushOptions o
#if MIN_VERSION_base(4,9,0)
instance {-# OVERLAPPABLE #-} (GObject a, O.UnknownAncestorError PushOptions a) =>
    IsPushOptions a
#endif
instance IsPushOptions PushOptions
instance GObject.Object.IsObject PushOptions

toPushOptions :: (MonadIO m, IsPushOptions o) => o -> m PushOptions
toPushOptions = liftIO . unsafeCastTo PushOptions

noPushOptions :: Maybe PushOptions
noPushOptions = Nothing

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
type family ResolvePushOptionsMethod (t :: Symbol) (o :: *) :: * where
    ResolvePushOptionsMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
    ResolvePushOptionsMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
    ResolvePushOptionsMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
    ResolvePushOptionsMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
    ResolvePushOptionsMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
    ResolvePushOptionsMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
    ResolvePushOptionsMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
    ResolvePushOptionsMethod "ref" o = GObject.Object.ObjectRefMethodInfo
    ResolvePushOptionsMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
    ResolvePushOptionsMethod "replaceData" o = GObject.Object.ObjectReplaceDataMethodInfo
    ResolvePushOptionsMethod "replaceQdata" o = GObject.Object.ObjectReplaceQdataMethodInfo
    ResolvePushOptionsMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
    ResolvePushOptionsMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
    ResolvePushOptionsMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
    ResolvePushOptionsMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
    ResolvePushOptionsMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
    ResolvePushOptionsMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
    ResolvePushOptionsMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
    ResolvePushOptionsMethod "getParallelism" o = PushOptionsGetParallelismMethodInfo
    ResolvePushOptionsMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
    ResolvePushOptionsMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
    ResolvePushOptionsMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
    ResolvePushOptionsMethod "setParallelism" o = PushOptionsSetParallelismMethodInfo
    ResolvePushOptionsMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
    ResolvePushOptionsMethod l o = O.MethodResolutionFailed l o

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

#if MIN_VERSION_base(4,9,0)
instance (info ~ ResolvePushOptionsMethod t PushOptions, O.MethodInfo info PushOptions p) => O.IsLabel t (PushOptions -> 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

-- VVV Prop "parallelism"
   -- Type: TBasicType TInt
   -- Flags: [PropertyReadable,PropertyWritable,PropertyConstruct]
   -- Nullable: (Just False,Just False)

getPushOptionsParallelism :: (MonadIO m, IsPushOptions o) => o -> m Int32
getPushOptionsParallelism obj = liftIO $ getObjectPropertyInt32 obj "parallelism"

setPushOptionsParallelism :: (MonadIO m, IsPushOptions o) => o -> Int32 -> m ()
setPushOptionsParallelism obj val = liftIO $ setObjectPropertyInt32 obj "parallelism" val

constructPushOptionsParallelism :: (IsPushOptions o) => Int32 -> IO (GValueConstruct o)
constructPushOptionsParallelism val = constructObjectPropertyInt32 "parallelism" val

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data PushOptionsParallelismPropertyInfo
instance AttrInfo PushOptionsParallelismPropertyInfo where
    type AttrAllowedOps PushOptionsParallelismPropertyInfo = '[ 'AttrSet, 'AttrConstruct, 'AttrGet]
    type AttrSetTypeConstraint PushOptionsParallelismPropertyInfo = (~) Int32
    type AttrBaseTypeConstraint PushOptionsParallelismPropertyInfo = IsPushOptions
    type AttrGetType PushOptionsParallelismPropertyInfo = Int32
    type AttrLabel PushOptionsParallelismPropertyInfo = "parallelism"
    type AttrOrigin PushOptionsParallelismPropertyInfo = PushOptions
    attrGet _ = getPushOptionsParallelism
    attrSet _ = setPushOptionsParallelism
    attrConstruct _ = constructPushOptionsParallelism
    attrClear _ = undefined
#endif

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
instance O.HasAttributeList PushOptions
type instance O.AttributeList PushOptions = PushOptionsAttributeList
type PushOptionsAttributeList = ('[ '("parallelism", PushOptionsParallelismPropertyInfo)] :: [(Symbol, *)])
#endif

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
pushOptionsParallelism :: AttrLabelProxy "parallelism"
pushOptionsParallelism = AttrLabelProxy

#endif

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
type instance O.SignalList PushOptions = PushOptionsSignalList
type PushOptionsSignalList = ('[ '("notify", GObject.Object.ObjectNotifySignalInfo)] :: [(Symbol, *)])

#endif

-- method PushOptions::new
-- method type : Constructor
-- Args : []
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Ggit", name = "PushOptions"}))
-- throws : False
-- Skip return : False

foreign import ccall "ggit_push_options_new" ggit_push_options_new :: 
    IO (Ptr PushOptions)

{- |
Create a new push options object.
-}
pushOptionsNew ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    m PushOptions
    {- ^ __Returns:__ a 'GI.Ggit.Objects.PushOptions.PushOptions'. -}
pushOptionsNew  = liftIO $ do
    result <- ggit_push_options_new
    checkUnexpectedReturnNULL "pushOptionsNew" result
    result' <- (wrapObject PushOptions) result
    return result'

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
#endif

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

foreign import ccall "ggit_push_options_get_parallelism" ggit_push_options_get_parallelism :: 
    Ptr PushOptions ->                      -- options : TInterface (Name {namespace = "Ggit", name = "PushOptions"})
    IO Int32

{- |
Get the number of parallel threads to use when creating the pack file
to push. The special value 0 indicates that the number of threads will
be automatically detected.
-}
pushOptionsGetParallelism ::
    (B.CallStack.HasCallStack, MonadIO m, IsPushOptions a) =>
    a
    {- ^ /@options@/: a 'GI.Ggit.Objects.PushOptions.PushOptions'. -}
    -> m Int32
    {- ^ __Returns:__ the number of parallel threads, or 0 for auto-detect. -}
pushOptionsGetParallelism options = liftIO $ do
    options' <- unsafeManagedPtrCastPtr options
    result <- ggit_push_options_get_parallelism options'
    touchManagedPtr options
    return result

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data PushOptionsGetParallelismMethodInfo
instance (signature ~ (m Int32), MonadIO m, IsPushOptions a) => O.MethodInfo PushOptionsGetParallelismMethodInfo a signature where
    overloadedMethod _ = pushOptionsGetParallelism

#endif

-- method PushOptions::set_parallelism
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "options", argType = TInterface (Name {namespace = "Ggit", name = "PushOptions"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GgitPushOptions.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "parallelism", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the number of threads, or 0 for auto-detect.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "ggit_push_options_set_parallelism" ggit_push_options_set_parallelism :: 
    Ptr PushOptions ->                      -- options : TInterface (Name {namespace = "Ggit", name = "PushOptions"})
    Int32 ->                                -- parallelism : TBasicType TInt
    IO ()

{- |
Set the number of parallel threads to use when creating the pack file
to push. The special value 0 can be specified for /@parallelism@/ indicating that
the number of threads will be automatically detected.
-}
pushOptionsSetParallelism ::
    (B.CallStack.HasCallStack, MonadIO m, IsPushOptions a) =>
    a
    {- ^ /@options@/: a 'GI.Ggit.Objects.PushOptions.PushOptions'. -}
    -> Int32
    {- ^ /@parallelism@/: the number of threads, or 0 for auto-detect. -}
    -> m ()
pushOptionsSetParallelism options parallelism = liftIO $ do
    options' <- unsafeManagedPtrCastPtr options
    ggit_push_options_set_parallelism options' parallelism
    touchManagedPtr options
    return ()

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data PushOptionsSetParallelismMethodInfo
instance (signature ~ (Int32 -> m ()), MonadIO m, IsPushOptions a) => O.MethodInfo PushOptionsSetParallelismMethodInfo a signature where
    overloadedMethod _ = pushOptionsSetParallelism

#endif