gi-gst-1.0.18: GI/Gst/Structs/DebugCategory.hs
{- |
Copyright : Will Thompson, Iñaki García Etxebarria and Jonas Platte
License : LGPL-2.1
Maintainer : Iñaki García Etxebarria (inaki@blueleaf.cc)
This is the struct that describes the categories. Once initialized with
@/GST_DEBUG_CATEGORY_INIT/@, its values can\'t be changed anymore.
-}
#define ENABLE_OVERLOADING (MIN_VERSION_haskell_gi_overloading(1,0,0) \
&& !defined(__HADDOCK_VERSION__))
module GI.Gst.Structs.DebugCategory
(
-- * Exported types
DebugCategory(..) ,
newZeroDebugCategory ,
noDebugCategory ,
-- * Methods
-- ** free #method:free#
#if ENABLE_OVERLOADING
DebugCategoryFreeMethodInfo ,
#endif
debugCategoryFree ,
-- ** getColor #method:getColor#
#if ENABLE_OVERLOADING
DebugCategoryGetColorMethodInfo ,
#endif
debugCategoryGetColor ,
-- ** getDescription #method:getDescription#
#if ENABLE_OVERLOADING
DebugCategoryGetDescriptionMethodInfo ,
#endif
debugCategoryGetDescription ,
-- ** getName #method:getName#
#if ENABLE_OVERLOADING
DebugCategoryGetNameMethodInfo ,
#endif
debugCategoryGetName ,
-- ** getThreshold #method:getThreshold#
#if ENABLE_OVERLOADING
DebugCategoryGetThresholdMethodInfo ,
#endif
debugCategoryGetThreshold ,
-- ** resetThreshold #method:resetThreshold#
#if ENABLE_OVERLOADING
DebugCategoryResetThresholdMethodInfo ,
#endif
debugCategoryResetThreshold ,
-- ** setThreshold #method:setThreshold#
#if ENABLE_OVERLOADING
DebugCategorySetThresholdMethodInfo ,
#endif
debugCategorySetThreshold ,
) 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.GClosure as B.GClosure
import qualified Data.GI.Base.GError as B.GError
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.Text as T
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 {-# SOURCE #-} qualified GI.Gst.Enums as Gst.Enums
-- | Memory-managed wrapper type.
newtype DebugCategory = DebugCategory (ManagedPtr DebugCategory)
instance WrappedPtr DebugCategory where
wrappedPtrCalloc = callocBytes 24
wrappedPtrCopy = \p -> withManagedPtr p (copyBytes 24 >=> wrapPtr DebugCategory)
wrappedPtrFree = Just ptr_to_g_free
-- | Construct a `DebugCategory` struct initialized to zero.
newZeroDebugCategory :: MonadIO m => m DebugCategory
newZeroDebugCategory = liftIO $ wrappedPtrCalloc >>= wrapPtr DebugCategory
instance tag ~ 'AttrSet => Constructible DebugCategory tag where
new _ attrs = do
o <- newZeroDebugCategory
GI.Attributes.set o attrs
return o
-- | A convenience alias for `Nothing` :: `Maybe` `DebugCategory`.
noDebugCategory :: Maybe DebugCategory
noDebugCategory = Nothing
#if ENABLE_OVERLOADING
instance O.HasAttributeList DebugCategory
type instance O.AttributeList DebugCategory = DebugCategoryAttributeList
type DebugCategoryAttributeList = ('[ ] :: [(Symbol, *)])
#endif
-- method DebugCategory::free
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "category", argType = TInterface (Name {namespace = "Gst", name = "DebugCategory"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "#GstDebugCategory to free.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False
foreign import ccall "gst_debug_category_free" gst_debug_category_free ::
Ptr DebugCategory -> -- category : TInterface (Name {namespace = "Gst", name = "DebugCategory"})
IO ()
{- |
Removes and frees the category and all associated resources.
-}
debugCategoryFree ::
(B.CallStack.HasCallStack, MonadIO m) =>
DebugCategory
{- ^ /@category@/: 'GI.Gst.Structs.DebugCategory.DebugCategory' to free. -}
-> m ()
debugCategoryFree category = liftIO $ do
category' <- unsafeManagedPtrGetPtr category
gst_debug_category_free category'
touchManagedPtr category
return ()
#if ENABLE_OVERLOADING
data DebugCategoryFreeMethodInfo
instance (signature ~ (m ()), MonadIO m) => O.MethodInfo DebugCategoryFreeMethodInfo DebugCategory signature where
overloadedMethod _ = debugCategoryFree
#endif
-- method DebugCategory::get_color
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "category", argType = TInterface (Name {namespace = "Gst", name = "DebugCategory"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstDebugCategory to get the color of.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUInt)
-- throws : False
-- Skip return : False
foreign import ccall "gst_debug_category_get_color" gst_debug_category_get_color ::
Ptr DebugCategory -> -- category : TInterface (Name {namespace = "Gst", name = "DebugCategory"})
IO Word32
{- |
Returns the color of a debug category used when printing output in this
category.
-}
debugCategoryGetColor ::
(B.CallStack.HasCallStack, MonadIO m) =>
DebugCategory
{- ^ /@category@/: a 'GI.Gst.Structs.DebugCategory.DebugCategory' to get the color of. -}
-> m Word32
{- ^ __Returns:__ the color of the category. -}
debugCategoryGetColor category = liftIO $ do
category' <- unsafeManagedPtrGetPtr category
result <- gst_debug_category_get_color category'
touchManagedPtr category
return result
#if ENABLE_OVERLOADING
data DebugCategoryGetColorMethodInfo
instance (signature ~ (m Word32), MonadIO m) => O.MethodInfo DebugCategoryGetColorMethodInfo DebugCategory signature where
overloadedMethod _ = debugCategoryGetColor
#endif
-- method DebugCategory::get_description
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "category", argType = TInterface (Name {namespace = "Gst", name = "DebugCategory"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstDebugCategory to get the description of.", 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 "gst_debug_category_get_description" gst_debug_category_get_description ::
Ptr DebugCategory -> -- category : TInterface (Name {namespace = "Gst", name = "DebugCategory"})
IO CString
{- |
Returns the description of a debug category.
-}
debugCategoryGetDescription ::
(B.CallStack.HasCallStack, MonadIO m) =>
DebugCategory
{- ^ /@category@/: a 'GI.Gst.Structs.DebugCategory.DebugCategory' to get the description of. -}
-> m T.Text
{- ^ __Returns:__ the description of the category. -}
debugCategoryGetDescription category = liftIO $ do
category' <- unsafeManagedPtrGetPtr category
result <- gst_debug_category_get_description category'
checkUnexpectedReturnNULL "debugCategoryGetDescription" result
result' <- cstringToText result
touchManagedPtr category
return result'
#if ENABLE_OVERLOADING
data DebugCategoryGetDescriptionMethodInfo
instance (signature ~ (m T.Text), MonadIO m) => O.MethodInfo DebugCategoryGetDescriptionMethodInfo DebugCategory signature where
overloadedMethod _ = debugCategoryGetDescription
#endif
-- method DebugCategory::get_name
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "category", argType = TInterface (Name {namespace = "Gst", name = "DebugCategory"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstDebugCategory to get name of.", 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 "gst_debug_category_get_name" gst_debug_category_get_name ::
Ptr DebugCategory -> -- category : TInterface (Name {namespace = "Gst", name = "DebugCategory"})
IO CString
{- |
Returns the name of a debug category.
-}
debugCategoryGetName ::
(B.CallStack.HasCallStack, MonadIO m) =>
DebugCategory
{- ^ /@category@/: a 'GI.Gst.Structs.DebugCategory.DebugCategory' to get name of. -}
-> m T.Text
{- ^ __Returns:__ the name of the category. -}
debugCategoryGetName category = liftIO $ do
category' <- unsafeManagedPtrGetPtr category
result <- gst_debug_category_get_name category'
checkUnexpectedReturnNULL "debugCategoryGetName" result
result' <- cstringToText result
touchManagedPtr category
return result'
#if ENABLE_OVERLOADING
data DebugCategoryGetNameMethodInfo
instance (signature ~ (m T.Text), MonadIO m) => O.MethodInfo DebugCategoryGetNameMethodInfo DebugCategory signature where
overloadedMethod _ = debugCategoryGetName
#endif
-- method DebugCategory::get_threshold
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "category", argType = TInterface (Name {namespace = "Gst", name = "DebugCategory"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstDebugCategory to get threshold of.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gst", name = "DebugLevel"}))
-- throws : False
-- Skip return : False
foreign import ccall "gst_debug_category_get_threshold" gst_debug_category_get_threshold ::
Ptr DebugCategory -> -- category : TInterface (Name {namespace = "Gst", name = "DebugCategory"})
IO CUInt
{- |
Returns the threshold of a 'GI.Gst.Structs.DebugCategory.DebugCategory'.
-}
debugCategoryGetThreshold ::
(B.CallStack.HasCallStack, MonadIO m) =>
DebugCategory
{- ^ /@category@/: a 'GI.Gst.Structs.DebugCategory.DebugCategory' to get threshold of. -}
-> m Gst.Enums.DebugLevel
{- ^ __Returns:__ the 'GI.Gst.Enums.DebugLevel' that is used as threshold. -}
debugCategoryGetThreshold category = liftIO $ do
category' <- unsafeManagedPtrGetPtr category
result <- gst_debug_category_get_threshold category'
let result' = (toEnum . fromIntegral) result
touchManagedPtr category
return result'
#if ENABLE_OVERLOADING
data DebugCategoryGetThresholdMethodInfo
instance (signature ~ (m Gst.Enums.DebugLevel), MonadIO m) => O.MethodInfo DebugCategoryGetThresholdMethodInfo DebugCategory signature where
overloadedMethod _ = debugCategoryGetThreshold
#endif
-- method DebugCategory::reset_threshold
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "category", argType = TInterface (Name {namespace = "Gst", name = "DebugCategory"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstDebugCategory to reset threshold of.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False
foreign import ccall "gst_debug_category_reset_threshold" gst_debug_category_reset_threshold ::
Ptr DebugCategory -> -- category : TInterface (Name {namespace = "Gst", name = "DebugCategory"})
IO ()
{- |
Resets the threshold of the category to the default level. Debug information
will only be output if the threshold is lower or equal to the level of the
debugging message.
Use this function to set the threshold back to where it was after using
'GI.Gst.Structs.DebugCategory.debugCategorySetThreshold'.
-}
debugCategoryResetThreshold ::
(B.CallStack.HasCallStack, MonadIO m) =>
DebugCategory
{- ^ /@category@/: a 'GI.Gst.Structs.DebugCategory.DebugCategory' to reset threshold of. -}
-> m ()
debugCategoryResetThreshold category = liftIO $ do
category' <- unsafeManagedPtrGetPtr category
gst_debug_category_reset_threshold category'
touchManagedPtr category
return ()
#if ENABLE_OVERLOADING
data DebugCategoryResetThresholdMethodInfo
instance (signature ~ (m ()), MonadIO m) => O.MethodInfo DebugCategoryResetThresholdMethodInfo DebugCategory signature where
overloadedMethod _ = debugCategoryResetThreshold
#endif
-- method DebugCategory::set_threshold
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "category", argType = TInterface (Name {namespace = "Gst", name = "DebugCategory"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstDebugCategory to set threshold of.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "level", argType = TInterface (Name {namespace = "Gst", name = "DebugLevel"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GstDebugLevel threshold to set.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False
foreign import ccall "gst_debug_category_set_threshold" gst_debug_category_set_threshold ::
Ptr DebugCategory -> -- category : TInterface (Name {namespace = "Gst", name = "DebugCategory"})
CUInt -> -- level : TInterface (Name {namespace = "Gst", name = "DebugLevel"})
IO ()
{- |
Sets the threshold of the category to the given level. Debug information will
only be output if the threshold is lower or equal to the level of the
debugging message.
> Do not use this function in production code, because other functions may
> change the threshold of categories as side effect. It is however a nice
> function to use when debugging (even from gdb).
-}
debugCategorySetThreshold ::
(B.CallStack.HasCallStack, MonadIO m) =>
DebugCategory
{- ^ /@category@/: a 'GI.Gst.Structs.DebugCategory.DebugCategory' to set threshold of. -}
-> Gst.Enums.DebugLevel
{- ^ /@level@/: the 'GI.Gst.Enums.DebugLevel' threshold to set. -}
-> m ()
debugCategorySetThreshold category level = liftIO $ do
category' <- unsafeManagedPtrGetPtr category
let level' = (fromIntegral . fromEnum) level
gst_debug_category_set_threshold category' level'
touchManagedPtr category
return ()
#if ENABLE_OVERLOADING
data DebugCategorySetThresholdMethodInfo
instance (signature ~ (Gst.Enums.DebugLevel -> m ()), MonadIO m) => O.MethodInfo DebugCategorySetThresholdMethodInfo DebugCategory signature where
overloadedMethod _ = debugCategorySetThreshold
#endif
#if ENABLE_OVERLOADING
type family ResolveDebugCategoryMethod (t :: Symbol) (o :: *) :: * where
ResolveDebugCategoryMethod "free" o = DebugCategoryFreeMethodInfo
ResolveDebugCategoryMethod "resetThreshold" o = DebugCategoryResetThresholdMethodInfo
ResolveDebugCategoryMethod "getColor" o = DebugCategoryGetColorMethodInfo
ResolveDebugCategoryMethod "getDescription" o = DebugCategoryGetDescriptionMethodInfo
ResolveDebugCategoryMethod "getName" o = DebugCategoryGetNameMethodInfo
ResolveDebugCategoryMethod "getThreshold" o = DebugCategoryGetThresholdMethodInfo
ResolveDebugCategoryMethod "setThreshold" o = DebugCategorySetThresholdMethodInfo
ResolveDebugCategoryMethod l o = O.MethodResolutionFailed l o
instance (info ~ ResolveDebugCategoryMethod t DebugCategory, O.MethodInfo info DebugCategory p) => OL.IsLabel t (DebugCategory -> 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