Debian Codegraph @

lib/wp/object-interest.h

raw
1 /* WirePlumber
2 *
3 * Copyright © 2020 Collabora Ltd.
4 * @author George Kiagiadakis <[email protected]>
5 *
6 * SPDX-License-Identifier: MIT
7 */
8
9 #ifndef __WIREPLUMBER_OBJECT_INTEREST_H__
10 #define __WIREPLUMBER_OBJECT_INTEREST_H__
11
12 #include <glib-object.h>
13 #include "defs.h"
14 #include "properties.h"
15
16 G_BEGIN_DECLS
17
18 /*!
19 * \brief Constraint types for wp_object_interest_add_constraint()
20 * \ingroup wpobjectinterest
21 */
22 typedef enum {
23 /*! invalid constraint type */
24 WP_CONSTRAINT_TYPE_NONE = 0,
25 /*! constraint applies to a PipeWire global property of the object
26 * (the ones returned by wp_global_proxy_get_global_properties()) */
27 WP_CONSTRAINT_TYPE_PW_GLOBAL_PROPERTY,
28 /*! constraint applies to a PipeWire property of the object
29 * (the ones returned by wp_pipewire_object_get_properties()) */
30 WP_CONSTRAINT_TYPE_PW_PROPERTY,
31 /*! constraint applies to a GObject property of the object */
32 WP_CONSTRAINT_TYPE_G_PROPERTY,
33 } WpConstraintType;
34
35 /*!
36 * \brief Verbs to use with wp_object_interest_add_constraint()
37 * \ingroup wpobjectinterest
38 */
39 typedef enum {
40 /*! the subject's value must equal the constraint's value */
41 WP_CONSTRAINT_VERB_EQUALS = '=',
42 /*! the subject's value must be different from the constraint's value */
43 WP_CONSTRAINT_VERB_NOT_EQUALS = '!',
44 /*! the subject's value must equal at least
45 * one of the values in the list given as the constraint's value */
46 WP_CONSTRAINT_VERB_IN_LIST = 'c',
47 /*! the subject's value must be a number in the range defined
48 * by the constraint's value */
49 WP_CONSTRAINT_VERB_IN_RANGE = '~',
50 /*! the subject's value must match the pattern specified in the
51 * constraint's value */
52 WP_CONSTRAINT_VERB_MATCHES = '#',
53 /*! the subject property must exist */
54 WP_CONSTRAINT_VERB_IS_PRESENT = '+',
55 /*! the subject property must not exist */
56 WP_CONSTRAINT_VERB_IS_ABSENT = '-',
57 } WpConstraintVerb;
58
59 /*!
60 * \brief Flags that indicate which constraints have been matched in
61 * wp_object_interest_matches_full()
62 * \ingroup wpobjectinterest
63 */
64 typedef enum { /*< flags >*/
65 WP_INTEREST_MATCH_NONE = 0,
66 WP_INTEREST_MATCH_GTYPE = (1 << 0),
67 WP_INTEREST_MATCH_PW_GLOBAL_PROPERTIES = (1 << 1),
68 WP_INTEREST_MATCH_PW_PROPERTIES = (1 << 2),
69 WP_INTEREST_MATCH_G_PROPERTIES = (1 << 3),
70
71 /*!
72 * Special WpInterestMatch value that indicates that all constraints
73 * have been matched
74 */
75 WP_INTEREST_MATCH_ALL =
76 (WP_INTEREST_MATCH_GTYPE |
77 WP_INTEREST_MATCH_PW_GLOBAL_PROPERTIES |
78 WP_INTEREST_MATCH_PW_PROPERTIES |
79 WP_INTEREST_MATCH_G_PROPERTIES),
80 } WpInterestMatch;
81
82 /*!
83 * \brief Flags to alter the behaviour of wp_object_interest_matches_full()
84 * \ingroup wpobjectinterest
85 */
86 typedef enum { /*< flags >*/
87 WP_INTEREST_MATCH_FLAGS_NONE = 0,
88 /*! check all the constraints instead of returning after the first mismatch */
89 WP_INTEREST_MATCH_FLAGS_CHECK_ALL = (1 << 0),
90 } WpInterestMatchFlags;
91
92 /*!
93 * \brief The WpObjectInterest GType
94 * \ingroup wpobjectinterest
95 */
96 #define WP_TYPE_OBJECT_INTEREST (wp_object_interest_get_type ())
97 WP_API
98 GType wp_object_interest_get_type (void) G_GNUC_CONST;
99
100 typedef struct _WpObjectInterest WpObjectInterest;
101
102 WP_API
103 WpObjectInterest * wp_object_interest_new (GType gtype, ...) G_GNUC_NULL_TERMINATED;
104
105 WP_API
106 WpObjectInterest * wp_object_interest_new_valist (GType gtype, va_list * args);
107
108 WP_API
109 WpObjectInterest * wp_object_interest_new_type (GType gtype);
110
111 WP_API
112 void wp_object_interest_add_constraint (WpObjectInterest * self,
113 WpConstraintType type, const gchar * subject,
114 WpConstraintVerb verb, GVariant * value);
115
116 WP_API
117 WpObjectInterest * wp_object_interest_ref (WpObjectInterest *self);
118
119 WP_API
120 void wp_object_interest_unref (WpObjectInterest * self);
121
122 WP_API
123 gboolean wp_object_interest_validate (WpObjectInterest * self, GError ** error);
124
125 WP_API
126 gboolean wp_object_interest_matches (WpObjectInterest * self, gpointer object);
127
128 WP_API
129 WpInterestMatch wp_object_interest_matches_full (WpObjectInterest * self,
130 WpInterestMatchFlags flags, GType object_type, gpointer object,
131 WpProperties * pw_props, WpProperties * pw_global_props);
132
133 WP_API
134 GPtrArray * wp_object_interest_find_defined_constraint_values (
135 WpObjectInterest * self, WpConstraintType type, const gchar * subject);
136
137 G_DEFINE_AUTOPTR_CLEANUP_FUNC (WpObjectInterest, wp_object_interest_unref)
138
139 G_END_DECLS
140
141 #endif