-enum cond_trigger_func_type {
- COND_TRIGGER_FUNC_TYPE_BASIC,
- COND_TRIGGER_FUNC_TYPE_RUN_IN_COMP_CLS_INIT,
+#include <functional>
+#include <memory>
+#include <string>
+#include <utility>
+#include <vector>
+
+#include <babeltrace2/babeltrace.h>
+
+#include "cpp-common/bt2c/c-string-view.hpp"
+#include "cpp-common/bt2s/span.hpp"
+
+#include "../utils/run-in.hpp"
+
+/*
+ * Abstract condition trigger class.
+ *
+ * A derived class must provide operator()() which triggers a condition
+ * of which the specific type (precondition or postcondition) and ID are
+ * provided at construction time.
+ */
+class CondTrigger
+{
+public:
+ using UP = std::unique_ptr<CondTrigger>;
+
+ /*
+ * Condition type.
+ */
+ enum class Type
+ {
+ Pre,
+ Post,
+ };
+
+protected:
+ /*
+ * Builds a condition trigger having the type `type`, the condition
+ * ID `condId` (_without_ any `pre:` or `post:` prefix), and the
+ * optional name suffix `nameSuffix`.
+ *
+ * The concatenation of `condId` and, if it's set, `-` and
+ * `*nameSuffix`, forms the name of the condition trigger. Get the
+ * name of the created condition trigger with name().
+ */
+ explicit CondTrigger(Type type, const std::string& condId,
+ const bt2c::CStringView nameSuffix) noexcept;
+
+public:
+ virtual ~CondTrigger() = default;
+ virtual void operator()() noexcept = 0;
+
+ Type type() const noexcept
+ {
+ return _mType;
+ }
+
+ /*
+ * Condition ID, including any `pre:` or `post:` prefix.
+ */
+ const std::string& condId() const noexcept
+ {
+ return _mCondId;
+ }
+
+ const std::string& name() const noexcept
+ {
+ return _mName;
+ }
+
+private:
+ Type _mType;
+ std::string _mCondId;
+ std::string _mName;