Modifier event predicate
This commit is contained in:
parent
8e6795a051
commit
f67a8842cc
12
config.c
12
config.c
|
@ -275,6 +275,9 @@ parse_event_predicate_type(const char *name)
|
||||||
if (strcmp(name, "disjunction") == 0 || strcmp(name, "or") == 0) {
|
if (strcmp(name, "disjunction") == 0 || strcmp(name, "or") == 0) {
|
||||||
return EVPRED_DISJUNCTION;
|
return EVPRED_DISJUNCTION;
|
||||||
}
|
}
|
||||||
|
if (strcmp(name, "modifier") == 0) {
|
||||||
|
return EVPRED_MODIFIER;
|
||||||
|
}
|
||||||
return EVPRED_INVALID;
|
return EVPRED_INVALID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -324,6 +327,15 @@ load_single_predicate(const config_setting_t * setting, EventPredicateHandleRegi
|
||||||
predicate.aggregate_data.handles = handles;
|
predicate.aggregate_data.handles = handles;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case EVPRED_MODIFIER:
|
||||||
|
{
|
||||||
|
long long modifier = resolve_constant_or(constants, config_setting_get_member(setting, "modifier"), -1);
|
||||||
|
if (modifier < 0 || modifier > MODIFIER_MAX) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
predicate.single_modifier = modifier;
|
||||||
|
}
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -168,6 +168,14 @@ event_predicate_apply(EventPredicateHandle handle, EventNode * event)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case EVPRED_MODIFIER:
|
||||||
|
if (!event) {
|
||||||
|
return EVPREDRES_DISABLED;
|
||||||
|
}
|
||||||
|
{
|
||||||
|
accepted = modifier_set_has(event->data.modifiers, ptr->single_modifier);
|
||||||
|
}
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
return EVPREDRES_DISABLED;
|
return EVPREDRES_DISABLED;
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,8 @@ typedef enum {
|
||||||
// Aggregation
|
// Aggregation
|
||||||
EVPRED_CONJUNCTION,
|
EVPRED_CONJUNCTION,
|
||||||
EVPRED_DISJUNCTION,
|
EVPRED_DISJUNCTION,
|
||||||
|
// Modifier
|
||||||
|
EVPRED_MODIFIER,
|
||||||
} EventPredicateType;
|
} EventPredicateType;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
@ -39,6 +41,7 @@ struct event_predicate {
|
||||||
size_t length;
|
size_t length;
|
||||||
EventPredicateHandle *handles;
|
EventPredicateHandle *handles;
|
||||||
} aggregate_data;
|
} aggregate_data;
|
||||||
|
Modifier single_modifier;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,7 @@ typedef struct {
|
||||||
typedef int32_t Modifier;
|
typedef int32_t Modifier;
|
||||||
|
|
||||||
#define EMPTY_MODIFIER_SET ((ModifierSet) {.byte_length = 0, .bits = NULL})
|
#define EMPTY_MODIFIER_SET ((ModifierSet) {.byte_length = 0, .bits = NULL})
|
||||||
|
#define MODIFIER_MAX ((Modifier) 0xFFFFF)
|
||||||
|
|
||||||
__attribute__((unused)) inline static ModifierSet
|
__attribute__((unused)) inline static ModifierSet
|
||||||
modifier_set_copy(const ModifierSet old)
|
modifier_set_copy(const ModifierSet old)
|
||||||
|
|
Loading…
Reference in New Issue