Copyright | Will Thompson and Iñaki García Etxebarria |
---|---|
License | LGPL-2.1 |
Maintainer | Iñaki García Etxebarria |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
MiniObject
is a simple structure that can be used to implement refcounted
types.
Subclasses will include MiniObject
as the first member in their structure
and then call gst_mini_object_init()
to initialize the MiniObject
fields.
gst_mini_object_ref()
and gst_mini_object_unref()
increment and decrement the
refcount respectively. When the refcount of a mini-object reaches 0, the
dispose function is called first and when this returns True
, the free
function of the miniobject is called.
A copy can be made with gst_mini_object_copy()
.
miniObjectIsWritable
will return True
when the refcount of the
object is exactly 1 and there is no parent or a single parent exists and is
writable itself, meaning the current caller has the only reference to the
object. gst_mini_object_make_writable()
will return a writable version of
the object, which might be a new copy when the refcount was not 1.
Opaque data can be associated with a MiniObject
with
miniObjectSetQdata
and miniObjectGetQdata
. The data is
meant to be specific to the particular object and is not automatically copied
with gst_mini_object_copy()
or similar methods.
A weak reference can be added and remove with gst_mini_object_weak_ref()
and gst_mini_object_weak_unref()
respectively.
Synopsis
- newtype MiniObject = MiniObject (ManagedPtr MiniObject)
- newZeroMiniObject :: MonadIO m => m MiniObject
- miniObjectAddParent :: (HasCallStack, MonadIO m) => MiniObject -> MiniObject -> m ()
- miniObjectGetQdata :: (HasCallStack, MonadIO m) => MiniObject -> Word32 -> m (Ptr ())
- miniObjectIsWritable :: (HasCallStack, MonadIO m) => MiniObject -> m Bool
- miniObjectLock :: (HasCallStack, MonadIO m) => MiniObject -> [LockFlags] -> m Bool
- miniObjectRemoveParent :: (HasCallStack, MonadIO m) => MiniObject -> MiniObject -> m ()
- miniObjectSetQdata :: (HasCallStack, MonadIO m) => MiniObject -> Word32 -> Ptr () -> DestroyNotify -> m ()
- miniObjectStealQdata :: (HasCallStack, MonadIO m) => MiniObject -> Word32 -> m (Ptr ())
- miniObjectUnlock :: (HasCallStack, MonadIO m) => MiniObject -> [LockFlags] -> m ()
- clearMiniObjectCopy :: MonadIO m => MiniObject -> m ()
- getMiniObjectCopy :: MonadIO m => MiniObject -> m (Maybe MiniObjectCopyFunction)
- setMiniObjectCopy :: MonadIO m => MiniObject -> FunPtr C_MiniObjectCopyFunction -> m ()
- clearMiniObjectDispose :: MonadIO m => MiniObject -> m ()
- getMiniObjectDispose :: MonadIO m => MiniObject -> m (Maybe MiniObjectDisposeFunction)
- setMiniObjectDispose :: MonadIO m => MiniObject -> FunPtr C_MiniObjectDisposeFunction -> m ()
- getMiniObjectFlags :: MonadIO m => MiniObject -> m Word32
- setMiniObjectFlags :: MonadIO m => MiniObject -> Word32 -> m ()
- clearMiniObjectFree :: MonadIO m => MiniObject -> m ()
- getMiniObjectFree :: MonadIO m => MiniObject -> m (Maybe MiniObjectFreeFunction)
- setMiniObjectFree :: MonadIO m => MiniObject -> FunPtr C_MiniObjectFreeFunction -> m ()
- getMiniObjectLockstate :: MonadIO m => MiniObject -> m Int32
- setMiniObjectLockstate :: MonadIO m => MiniObject -> Int32 -> m ()
- getMiniObjectRefcount :: MonadIO m => MiniObject -> m Int32
- setMiniObjectRefcount :: MonadIO m => MiniObject -> Int32 -> m ()
- getMiniObjectType :: MonadIO m => MiniObject -> m GType
- setMiniObjectType :: MonadIO m => MiniObject -> GType -> m ()
Exported types
newtype MiniObject Source #
Memory-managed wrapper type.
MiniObject (ManagedPtr MiniObject) |
Instances
newZeroMiniObject :: MonadIO m => m MiniObject Source #
Construct a MiniObject
struct initialized to zero.
Methods
Click to display all available methods, including inherited ones
addParent
:: (HasCallStack, MonadIO m) | |
=> MiniObject |
|
-> MiniObject |
|
-> m () |
This adds parent
as a parent for object
. Having one ore more parents affects the
writability of object
: if a parent
is not writable, object
is also not
writable, regardless of its refcount. object
is only writable if all
the parents are writable and its own refcount is exactly 1.
Note: This function does not take ownership of parent
and also does not
take an additional reference. It is the responsibility of the caller to
remove the parent again at a later time.
Since: 1.16
getQdata
:: (HasCallStack, MonadIO m) | |
=> MiniObject |
|
-> Word32 |
|
-> m (Ptr ()) | Returns: The user data pointer set, or
|
This function gets back user data pointers stored via
miniObjectSetQdata
.
isWritable
:: (HasCallStack, MonadIO m) | |
=> MiniObject |
|
-> m Bool | Returns: |
If miniObject
has the LOCKABLE flag set, check if the current EXCLUSIVE
lock on object
is the only one, this means that changes to the object will
not be visible to any other object.
If the LOCKABLE flag is not set, check if the refcount of miniObject
is
exactly 1, meaning that no other reference exists to the object and that the
object is therefore writable.
Modification of a mini-object should only be done after verifying that it is writable.
lock
:: (HasCallStack, MonadIO m) | |
=> MiniObject |
|
-> [LockFlags] |
|
-> m Bool | Returns: |
Lock the mini-object with the specified access mode in flags
.
removeParent
miniObjectRemoveParent Source #
:: (HasCallStack, MonadIO m) | |
=> MiniObject |
|
-> MiniObject |
|
-> m () |
This removes parent
as a parent for object
. See
miniObjectAddParent
.
Since: 1.16
setQdata
:: (HasCallStack, MonadIO m) | |
=> MiniObject |
|
-> Word32 |
|
-> Ptr () |
|
-> DestroyNotify |
|
-> m () |
This sets an opaque, named pointer on a miniobject.
The name is specified through a GQuark
(retrieved e.g. via
quarkFromStaticString
), and the pointer
can be gotten back from the object
with miniObjectGetQdata
until the object
is disposed.
Setting a previously set user data pointer, overrides (frees)
the old pointer set, using Nothing
as pointer essentially
removes the data stored.
destroy
may be specified which is called with data
as argument
when the object
is disposed, or the data is being overwritten by
a call to miniObjectSetQdata
with the same quark
.
stealQdata
:: (HasCallStack, MonadIO m) | |
=> MiniObject |
|
-> Word32 |
|
-> m (Ptr ()) | Returns: The user data pointer set, or
|
This function gets back user data pointers stored via miniObjectSetQdata
and removes the data from object
without invoking its destroy()
function (if
any was set).
unlock
:: (HasCallStack, MonadIO m) | |
=> MiniObject |
|
-> [LockFlags] |
|
-> m () |
Unlock the mini-object with the specified access mode in flags
.
Properties
copy
a copy function
clearMiniObjectCopy :: MonadIO m => MiniObject -> m () Source #
Set the value of the “copy
” field to Nothing
.
When overloading is enabled, this is equivalent to
clear
#copy
getMiniObjectCopy :: MonadIO m => MiniObject -> m (Maybe MiniObjectCopyFunction) Source #
Get the value of the “copy
” field.
When overloading is enabled, this is equivalent to
get
miniObject #copy
setMiniObjectCopy :: MonadIO m => MiniObject -> FunPtr C_MiniObjectCopyFunction -> m () Source #
Set the value of the “copy
” field.
When overloading is enabled, this is equivalent to
set
miniObject [ #copy:=
value ]
dispose
a dispose function
clearMiniObjectDispose :: MonadIO m => MiniObject -> m () Source #
Set the value of the “dispose
” field to Nothing
.
When overloading is enabled, this is equivalent to
clear
#dispose
getMiniObjectDispose :: MonadIO m => MiniObject -> m (Maybe MiniObjectDisposeFunction) Source #
Get the value of the “dispose
” field.
When overloading is enabled, this is equivalent to
get
miniObject #dispose
setMiniObjectDispose :: MonadIO m => MiniObject -> FunPtr C_MiniObjectDisposeFunction -> m () Source #
Set the value of the “dispose
” field.
When overloading is enabled, this is equivalent to
set
miniObject [ #dispose:=
value ]
flags
extra flags.
getMiniObjectFlags :: MonadIO m => MiniObject -> m Word32 Source #
Get the value of the “flags
” field.
When overloading is enabled, this is equivalent to
get
miniObject #flags
setMiniObjectFlags :: MonadIO m => MiniObject -> Word32 -> m () Source #
Set the value of the “flags
” field.
When overloading is enabled, this is equivalent to
set
miniObject [ #flags:=
value ]
free
the free function
clearMiniObjectFree :: MonadIO m => MiniObject -> m () Source #
Set the value of the “free
” field to Nothing
.
When overloading is enabled, this is equivalent to
clear
#free
getMiniObjectFree :: MonadIO m => MiniObject -> m (Maybe MiniObjectFreeFunction) Source #
Get the value of the “free
” field.
When overloading is enabled, this is equivalent to
get
miniObject #free
setMiniObjectFree :: MonadIO m => MiniObject -> FunPtr C_MiniObjectFreeFunction -> m () Source #
Set the value of the “free
” field.
When overloading is enabled, this is equivalent to
set
miniObject [ #free:=
value ]
lockstate
atomic state of the locks
getMiniObjectLockstate :: MonadIO m => MiniObject -> m Int32 Source #
Get the value of the “lockstate
” field.
When overloading is enabled, this is equivalent to
get
miniObject #lockstate
setMiniObjectLockstate :: MonadIO m => MiniObject -> Int32 -> m () Source #
Set the value of the “lockstate
” field.
When overloading is enabled, this is equivalent to
set
miniObject [ #lockstate:=
value ]
refcount
atomic refcount
getMiniObjectRefcount :: MonadIO m => MiniObject -> m Int32 Source #
Get the value of the “refcount
” field.
When overloading is enabled, this is equivalent to
get
miniObject #refcount
setMiniObjectRefcount :: MonadIO m => MiniObject -> Int32 -> m () Source #
Set the value of the “refcount
” field.
When overloading is enabled, this is equivalent to
set
miniObject [ #refcount:=
value ]
type
the GType of the object
getMiniObjectType :: MonadIO m => MiniObject -> m GType Source #
Get the value of the “type
” field.
When overloading is enabled, this is equivalent to
get
miniObject #type
setMiniObjectType :: MonadIO m => MiniObject -> GType -> m () Source #
Set the value of the “type
” field.
When overloading is enabled, this is equivalent to
set
miniObject [ #type:=
value ]