packages feed

gi-wireplumber-0.5.14: GI/Wp/Structs/ProcInfo.hs

{-# LANGUAGE TypeApplications #-}


-- | Copyright  : Will Thompson and Iñaki García Etxebarria
-- License    : LGPL-2.1
-- Maintainer : Iñaki García Etxebarria
-- 
-- WpProcInfo holds information of a process.

#if (MIN_VERSION_haskell_gi_overloading(1,0,0) && !defined(__HADDOCK_VERSION__))
#define ENABLE_OVERLOADING
#endif

module GI.Wp.Structs.ProcInfo
    ( 

-- * Exported types
    ProcInfo(..)                            ,


 -- * Methods
-- | 
-- 
--  === __Click to display all available methods, including inherited ones__
-- ==== Methods
-- [ref]("GI.Wp.Structs.ProcInfo#g:method:ref"), [unref]("GI.Wp.Structs.ProcInfo#g:method:unref").
-- 
-- ==== Getters
-- [getArg]("GI.Wp.Structs.ProcInfo#g:method:getArg"), [getCgroup]("GI.Wp.Structs.ProcInfo#g:method:getCgroup"), [getNArgs]("GI.Wp.Structs.ProcInfo#g:method:getNArgs"), [getParentPid]("GI.Wp.Structs.ProcInfo#g:method:getParentPid"), [getPid]("GI.Wp.Structs.ProcInfo#g:method:getPid").
-- 
-- ==== Setters
-- /None/.

#if defined(ENABLE_OVERLOADING)
    ResolveProcInfoMethod                   ,
#endif

-- ** getArg #method:getArg#

#if defined(ENABLE_OVERLOADING)
    ProcInfoGetArgMethodInfo                ,
#endif
    procInfoGetArg                          ,


-- ** getCgroup #method:getCgroup#

#if defined(ENABLE_OVERLOADING)
    ProcInfoGetCgroupMethodInfo             ,
#endif
    procInfoGetCgroup                       ,


-- ** getNArgs #method:getNArgs#

#if defined(ENABLE_OVERLOADING)
    ProcInfoGetNArgsMethodInfo              ,
#endif
    procInfoGetNArgs                        ,


-- ** getParentPid #method:getParentPid#

#if defined(ENABLE_OVERLOADING)
    ProcInfoGetParentPidMethodInfo          ,
#endif
    procInfoGetParentPid                    ,


-- ** getPid #method:getPid#

#if defined(ENABLE_OVERLOADING)
    ProcInfoGetPidMethodInfo                ,
#endif
    procInfoGetPid                          ,


-- ** ref #method:ref#

#if defined(ENABLE_OVERLOADING)
    ProcInfoRefMethodInfo                   ,
#endif
    procInfoRef                             ,


-- ** unref #method:unref#

#if defined(ENABLE_OVERLOADING)
    ProcInfoUnrefMethodInfo                 ,
#endif
    procInfoUnref                           ,




    ) 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.BasicTypes as B.Types
import qualified Data.GI.Base.ManagedPtr as B.ManagedPtr
import qualified Data.GI.Base.GArray as B.GArray
import qualified Data.GI.Base.GClosure as B.GClosure
import qualified Data.GI.Base.GError as B.GError
import qualified Data.GI.Base.GHashTable as B.GHT
import qualified Data.GI.Base.GVariant as B.GVariant
import qualified Data.GI.Base.GValue as B.GValue
import qualified Data.GI.Base.GParamSpec as B.GParamSpec
import qualified Data.GI.Base.CallStack as B.CallStack
import qualified Data.GI.Base.Properties as B.Properties
import qualified Data.GI.Base.Signals as B.Signals
import qualified Control.Monad.IO.Class as MIO
import qualified Data.Coerce as Coerce
import qualified Data.Text as T
import qualified Data.Kind as DK
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map
import qualified Foreign.Ptr as FP
import qualified GHC.OverloadedLabels as OL
import qualified GHC.Records as R
import qualified Data.Word as DW
import qualified Data.Int as DI
import qualified System.Posix.Types as SPT
import qualified Foreign.C.Types as FCT

-- Workaround for https://gitlab.haskell.org/ghc/ghc/-/issues/23392
#if MIN_VERSION_base(4,18,0)

#else

#endif

-- | Memory-managed wrapper type.
newtype ProcInfo = ProcInfo (SP.ManagedPtr ProcInfo)
    deriving (Eq)

instance SP.ManagedPtrNewtype ProcInfo where
    toManagedPtr (ProcInfo p) = p

foreign import ccall "wp_proc_info_get_type" c_wp_proc_info_get_type :: 
    IO GType

type instance O.ParentTypes ProcInfo = '[]
instance O.HasParentTypes ProcInfo

instance B.Types.TypedObject ProcInfo where
    glibType = c_wp_proc_info_get_type

instance B.Types.GBoxed ProcInfo

-- | Convert t'ProcInfo' to and from 'Data.GI.Base.GValue.GValue'. See 'Data.GI.Base.GValue.toGValue' and 'Data.GI.Base.GValue.fromGValue'.
instance B.GValue.IsGValue (Maybe ProcInfo) where
    gvalueGType_ = c_wp_proc_info_get_type
    gvalueSet_ gv P.Nothing = B.GValue.set_boxed gv (FP.nullPtr :: FP.Ptr ProcInfo)
    gvalueSet_ gv (P.Just obj) = B.ManagedPtr.withManagedPtr obj (B.GValue.set_boxed gv)
    gvalueGet_ gv = do
        ptr <- B.GValue.get_boxed gv :: IO (Ptr ProcInfo)
        if ptr /= FP.nullPtr
        then P.Just <$> B.ManagedPtr.newBoxed ProcInfo ptr
        else return P.Nothing
        
    


#if defined(ENABLE_OVERLOADING)
instance O.HasAttributeList ProcInfo
type instance O.AttributeList ProcInfo = ProcInfoAttributeList
type ProcInfoAttributeList = ('[ ] :: [(Symbol, DK.Type)])
#endif

-- method ProcInfo::get_arg
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "self"
--           , argType =
--               TInterface Name { namespace = "Wp" , name = "ProcInfo" }
--           , argCType = Just "WpProcInfo*"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the process information object"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "index"
--           , argType = TBasicType TUInt
--           , argCType = Just "guint"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the index of the arg"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "wp_proc_info_get_arg" wp_proc_info_get_arg :: 
    Ptr ProcInfo ->                         -- self : TInterface (Name {namespace = "Wp", name = "ProcInfo"})
    Word32 ->                               -- index : TBasicType TUInt
    IO CString

-- | Gets the indexed arg of a process information object.
procInfoGetArg ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    ProcInfo
    -- ^ /@self@/: the process information object
    -> Word32
    -- ^ /@index@/: the index of the arg
    -> m T.Text
    -- ^ __Returns:__ the indexed arg of the process information object
procInfoGetArg self index = liftIO $ do
    self' <- unsafeManagedPtrGetPtr self
    result <- wp_proc_info_get_arg self' index
    checkUnexpectedReturnNULL "procInfoGetArg" result
    result' <- cstringToText result
    touchManagedPtr self
    return result'

#if defined(ENABLE_OVERLOADING)
data ProcInfoGetArgMethodInfo
instance (signature ~ (Word32 -> m T.Text), MonadIO m) => O.OverloadedMethod ProcInfoGetArgMethodInfo ProcInfo signature where
    overloadedMethod = procInfoGetArg

instance O.OverloadedMethodInfo ProcInfoGetArgMethodInfo ProcInfo where
    overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.Wp.Structs.ProcInfo.procInfoGetArg",
        O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-wireplumber-0.5.14/docs/GI-Wp-Structs-ProcInfo.html#v:procInfoGetArg"
        })


#endif

-- method ProcInfo::get_cgroup
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "self"
--           , argType =
--               TInterface Name { namespace = "Wp" , name = "ProcInfo" }
--           , argCType = Just "WpProcInfo*"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the process information object"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "wp_proc_info_get_cgroup" wp_proc_info_get_cgroup :: 
    Ptr ProcInfo ->                         -- self : TInterface (Name {namespace = "Wp", name = "ProcInfo"})
    IO CString

-- | Gets the systemd cgroup of a process information object.
procInfoGetCgroup ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    ProcInfo
    -- ^ /@self@/: the process information object
    -> m T.Text
    -- ^ __Returns:__ the systemd cgroup of the process information object
procInfoGetCgroup self = liftIO $ do
    self' <- unsafeManagedPtrGetPtr self
    result <- wp_proc_info_get_cgroup self'
    checkUnexpectedReturnNULL "procInfoGetCgroup" result
    result' <- cstringToText result
    touchManagedPtr self
    return result'

#if defined(ENABLE_OVERLOADING)
data ProcInfoGetCgroupMethodInfo
instance (signature ~ (m T.Text), MonadIO m) => O.OverloadedMethod ProcInfoGetCgroupMethodInfo ProcInfo signature where
    overloadedMethod = procInfoGetCgroup

instance O.OverloadedMethodInfo ProcInfoGetCgroupMethodInfo ProcInfo where
    overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.Wp.Structs.ProcInfo.procInfoGetCgroup",
        O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-wireplumber-0.5.14/docs/GI-Wp-Structs-ProcInfo.html#v:procInfoGetCgroup"
        })


#endif

-- method ProcInfo::get_n_args
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "self"
--           , argType =
--               TInterface Name { namespace = "Wp" , name = "ProcInfo" }
--           , argCType = Just "WpProcInfo*"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the process information object"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TUInt)
-- throws : False
-- Skip return : False

foreign import ccall "wp_proc_info_get_n_args" wp_proc_info_get_n_args :: 
    Ptr ProcInfo ->                         -- self : TInterface (Name {namespace = "Wp", name = "ProcInfo"})
    IO Word32

-- | Gets the number of args of a process information object.
procInfoGetNArgs ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    ProcInfo
    -- ^ /@self@/: the process information object
    -> m Word32
    -- ^ __Returns:__ the number of args of the process information object
procInfoGetNArgs self = liftIO $ do
    self' <- unsafeManagedPtrGetPtr self
    result <- wp_proc_info_get_n_args self'
    touchManagedPtr self
    return result

#if defined(ENABLE_OVERLOADING)
data ProcInfoGetNArgsMethodInfo
instance (signature ~ (m Word32), MonadIO m) => O.OverloadedMethod ProcInfoGetNArgsMethodInfo ProcInfo signature where
    overloadedMethod = procInfoGetNArgs

instance O.OverloadedMethodInfo ProcInfoGetNArgsMethodInfo ProcInfo where
    overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.Wp.Structs.ProcInfo.procInfoGetNArgs",
        O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-wireplumber-0.5.14/docs/GI-Wp-Structs-ProcInfo.html#v:procInfoGetNArgs"
        })


#endif

-- method ProcInfo::get_parent_pid
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "self"
--           , argType =
--               TInterface Name { namespace = "Wp" , name = "ProcInfo" }
--           , argCType = Just "WpProcInfo*"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the process information object"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType Tpid_t)
-- throws : False
-- Skip return : False

foreign import ccall "wp_proc_info_get_parent_pid" wp_proc_info_get_parent_pid :: 
    Ptr ProcInfo ->                         -- self : TInterface (Name {namespace = "Wp", name = "ProcInfo"})
    IO DI.Int32

-- | Gets the parent PID of a process information object.
procInfoGetParentPid ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    ProcInfo
    -- ^ /@self@/: the process information object
    -> m DI.Int32
    -- ^ __Returns:__ the parent PID of the process information object
procInfoGetParentPid self = liftIO $ do
    self' <- unsafeManagedPtrGetPtr self
    result <- wp_proc_info_get_parent_pid self'
    touchManagedPtr self
    return result

#if defined(ENABLE_OVERLOADING)
data ProcInfoGetParentPidMethodInfo
instance (signature ~ (m DI.Int32), MonadIO m) => O.OverloadedMethod ProcInfoGetParentPidMethodInfo ProcInfo signature where
    overloadedMethod = procInfoGetParentPid

instance O.OverloadedMethodInfo ProcInfoGetParentPidMethodInfo ProcInfo where
    overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.Wp.Structs.ProcInfo.procInfoGetParentPid",
        O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-wireplumber-0.5.14/docs/GI-Wp-Structs-ProcInfo.html#v:procInfoGetParentPid"
        })


#endif

-- method ProcInfo::get_pid
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "self"
--           , argType =
--               TInterface Name { namespace = "Wp" , name = "ProcInfo" }
--           , argCType = Just "WpProcInfo*"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the process information object"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType Tpid_t)
-- throws : False
-- Skip return : False

foreign import ccall "wp_proc_info_get_pid" wp_proc_info_get_pid :: 
    Ptr ProcInfo ->                         -- self : TInterface (Name {namespace = "Wp", name = "ProcInfo"})
    IO DI.Int32

-- | Gets the PID of a process information object.
procInfoGetPid ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    ProcInfo
    -- ^ /@self@/: the process information object
    -> m DI.Int32
    -- ^ __Returns:__ the PID of the process information object
procInfoGetPid self = liftIO $ do
    self' <- unsafeManagedPtrGetPtr self
    result <- wp_proc_info_get_pid self'
    touchManagedPtr self
    return result

#if defined(ENABLE_OVERLOADING)
data ProcInfoGetPidMethodInfo
instance (signature ~ (m DI.Int32), MonadIO m) => O.OverloadedMethod ProcInfoGetPidMethodInfo ProcInfo signature where
    overloadedMethod = procInfoGetPid

instance O.OverloadedMethodInfo ProcInfoGetPidMethodInfo ProcInfo where
    overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.Wp.Structs.ProcInfo.procInfoGetPid",
        O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-wireplumber-0.5.14/docs/GI-Wp-Structs-ProcInfo.html#v:procInfoGetPid"
        })


#endif

-- method ProcInfo::ref
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "self"
--           , argType =
--               TInterface Name { namespace = "Wp" , name = "ProcInfo" }
--           , argCType = Just "WpProcInfo*"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a process information object"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TInterface Name { namespace = "Wp" , name = "ProcInfo" })
-- throws : False
-- Skip return : False

foreign import ccall "wp_proc_info_ref" wp_proc_info_ref :: 
    Ptr ProcInfo ->                         -- self : TInterface (Name {namespace = "Wp", name = "ProcInfo"})
    IO (Ptr ProcInfo)

-- | Increases the reference count of a process information object.
procInfoRef ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    ProcInfo
    -- ^ /@self@/: a process information object
    -> m ProcInfo
    -- ^ __Returns:__ /@self@/ with an additional reference count on it
procInfoRef self = liftIO $ do
    self' <- unsafeManagedPtrGetPtr self
    result <- wp_proc_info_ref self'
    checkUnexpectedReturnNULL "procInfoRef" result
    result' <- (wrapBoxed ProcInfo) result
    touchManagedPtr self
    return result'

#if defined(ENABLE_OVERLOADING)
data ProcInfoRefMethodInfo
instance (signature ~ (m ProcInfo), MonadIO m) => O.OverloadedMethod ProcInfoRefMethodInfo ProcInfo signature where
    overloadedMethod = procInfoRef

instance O.OverloadedMethodInfo ProcInfoRefMethodInfo ProcInfo where
    overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.Wp.Structs.ProcInfo.procInfoRef",
        O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-wireplumber-0.5.14/docs/GI-Wp-Structs-ProcInfo.html#v:procInfoRef"
        })


#endif

-- method ProcInfo::unref
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "self"
--           , argType =
--               TInterface Name { namespace = "Wp" , name = "ProcInfo" }
--           , argCType = Just "WpProcInfo*"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a process information object"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferEverything
--           }
--       ]
-- Lengths: []
-- returnType: Nothing
-- throws : False
-- Skip return : False

foreign import ccall "wp_proc_info_unref" wp_proc_info_unref :: 
    Ptr ProcInfo ->                         -- self : TInterface (Name {namespace = "Wp", name = "ProcInfo"})
    IO ()

-- | Decreases the reference count on /@self@/ and frees it when the ref count reaches zero.
procInfoUnref ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    ProcInfo
    -- ^ /@self@/: a process information object
    -> m ()
procInfoUnref self = liftIO $ do
    self' <- B.ManagedPtr.disownBoxed self
    wp_proc_info_unref self'
    touchManagedPtr self
    return ()

#if defined(ENABLE_OVERLOADING)
data ProcInfoUnrefMethodInfo
instance (signature ~ (m ()), MonadIO m) => O.OverloadedMethod ProcInfoUnrefMethodInfo ProcInfo signature where
    overloadedMethod = procInfoUnref

instance O.OverloadedMethodInfo ProcInfoUnrefMethodInfo ProcInfo where
    overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.Wp.Structs.ProcInfo.procInfoUnref",
        O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-wireplumber-0.5.14/docs/GI-Wp-Structs-ProcInfo.html#v:procInfoUnref"
        })


#endif

#if defined(ENABLE_OVERLOADING)
type family ResolveProcInfoMethod (t :: Symbol) (o :: DK.Type) :: DK.Type where
    ResolveProcInfoMethod "ref" o = ProcInfoRefMethodInfo
    ResolveProcInfoMethod "unref" o = ProcInfoUnrefMethodInfo
    ResolveProcInfoMethod "getArg" o = ProcInfoGetArgMethodInfo
    ResolveProcInfoMethod "getCgroup" o = ProcInfoGetCgroupMethodInfo
    ResolveProcInfoMethod "getNArgs" o = ProcInfoGetNArgsMethodInfo
    ResolveProcInfoMethod "getParentPid" o = ProcInfoGetParentPidMethodInfo
    ResolveProcInfoMethod "getPid" o = ProcInfoGetPidMethodInfo
    ResolveProcInfoMethod l o = O.MethodResolutionFailed l o

instance (info ~ ResolveProcInfoMethod t ProcInfo, O.OverloadedMethod info ProcInfo p) => OL.IsLabel t (ProcInfo -> p) where
#if MIN_VERSION_base(4,10,0)
    fromLabel = O.overloadedMethod @info
#else
    fromLabel _ = O.overloadedMethod @info
#endif

#if MIN_VERSION_base(4,13,0)
instance (info ~ ResolveProcInfoMethod t ProcInfo, O.OverloadedMethod info ProcInfo p, R.HasField t ProcInfo p) => R.HasField t ProcInfo p where
    getField = O.overloadedMethod @info

#endif

instance (info ~ ResolveProcInfoMethod t ProcInfo, O.OverloadedMethodInfo info ProcInfo) => OL.IsLabel t (O.MethodProxy info ProcInfo) where
#if MIN_VERSION_base(4,10,0)
    fromLabel = O.MethodProxy
#else
    fromLabel _ = O.MethodProxy
#endif

#endif