Meta
- class Meta(*args, **kwargs)
The Meta
structure should be included as the first member of a Buffer
metadata structure. The structure defines the API of the metadata and should
be accessible to all elements using the metadata.
A metadata API is registered with api_type_register()
which takes a
name for the metadata API and some tags associated with the metadata.
With api_type_has_tag()
one can check if a certain metadata API
contains a given tag.
Multiple implementations of a metadata API can be registered.
To implement a metadata API, register()
should be used. This
function takes all parameters needed to create, free and transform metadata
along with the size of the metadata. The function returns a MetaInfo
structure that contains the information for the implementation of the API.
A specific implementation can be retrieved by name with get_info()
.
See Buffer
for how the metadata can be added, retrieved and removed from
buffers.
Methods
- class Meta
-
- api_type_has_tag(api: type, tag: int) bool
Check if
api
was registered withtag
.- Parameters:
api – an API
tag – the tag to check
- api_type_register(api: str, tags: Sequence[str]) type
Register and return a GType for the
api
and associate it withtags
.- Parameters:
api – an API to register
tags – tags for
api
- compare_seqnum(meta2: Meta) int
Meta sequence number compare function. Can be used as
CompareFunc
or aCompareDataFunc
.Added in version 1.16.
- Parameters:
meta2 – a
Meta
- get_info(impl: str) MetaInfo | None
Lookup a previously registered meta info structure by its implementation name
impl
.- Parameters:
impl – the name
- register(api: type, impl: str, size: int, init_func: Callable[[Meta, None, Buffer], bool], free_func: Callable[[Meta, Buffer], None], transform_func: Callable[[Buffer, Meta, Buffer, int, None], bool]) MetaInfo
Register a new
Meta
implementation.The same
info
can be retrieved later withget_info()
by usingimpl
as the key.
- register_custom(name: str, tags: Sequence[str], transform_func: Callable[[...], bool] | None = None, *user_data: Any) MetaInfo
Register a new custom
Meta
implementation, backed by an opaque structure holding aStructure
.The registered info can be retrieved later with
get_info()
by usingname
as the key.The backing
Structure
can be retrieved withget_structure()
, its mutability is conditioned by the writability of the buffer the meta is attached to.When
transform_func
isNone
, the meta and its backingStructure
will always be copied when the transform operation is copy, other operations are discarded, copy regions are ignored.Added in version 1.20.
- Parameters:
name – the name of the
Meta
implementationtags – tags for
api
transform_func – a
MetaTransformFunction
user_data – user data passed to
transform_func