tests: fix some include guards
[babeltrace.git] / tests / lib / utils / run-in.hpp
index 01774f9053f5e424dcea154d84b31d73f3f955c2..f887d7a1c59b717011d4a7be5954347bda596fbf 100644 (file)
@@ -4,10 +4,8 @@
  * Copyright (C) 2020-2023 EfficiOS, inc.
  */
 
-#ifndef TESTS_LIB_UTILS_H
-#define TESTS_LIB_UTILS_H
-
-#include <functional>
+#ifndef TESTS_LIB_UTILS_RUN_IN_HPP
+#define TESTS_LIB_UTILS_RUN_IN_HPP
 
 #include <babeltrace2/babeltrace.h>
 
 #include "cpp-common/bt2/self-component-port.hpp"
 #include "cpp-common/bt2/self-message-iterator.hpp"
 
-using RunInCompClsQueryFunc = std::function<void(bt2::SelfComponentClass)>;
-using RunInCompClsInitFunc = std::function<void(bt2::SelfComponent)>;
-using RunInMsgIterClsInitFunc = std::function<void(bt2::SelfMessageIterator)>;
-
 /*
- * Runs:
- *
- * • `compClsCtxFunc` in the context of a component class method,
- *   if not `nullptr`.
+ * Base class from which to inherit to call runIn().
  *
- * • `compCtxFunc` in the context of a component method, if not
- *   `nullptr`.
- *
- * • `msgIterCtxFunc` in the context of a message iterator method, if
- *   not `nullptr`.
- */
-void runIn(RunInCompClsQueryFunc compClsCtxFunc, RunInCompClsInitFunc compCtxFunc,
-           RunInMsgIterClsInitFunc msgIterCtxFunc);
-
-/*
- * Runs `func` in the context of a component class method.
- */
-void runInCompClsQuery(RunInCompClsQueryFunc func);
-
-/*
- * Runs `func` in the context of a component method.
+ * Override any of the on*() methods to get your statements executed in
+ * a specific context.
  */
-void runInCompClsInit(RunInCompClsInitFunc func);
+class RunIn
+{
+public:
+    virtual ~RunIn() = default;
+
+    /*
+     * Called when querying the component class `self`.
+     */
+    virtual void onQuery(bt2::SelfComponentClass self);
+
+    /*
+     * Called when initializing the component `self`.
+     */
+    virtual void onCompInit(bt2::SelfComponent self);
+
+    /*
+     * Called when initializing the message iterator `self`.
+     */
+    virtual void onMsgIterInit(bt2::SelfMessageIterator self);
+};
 
 /*
- * Runs `func` in the context of a message iterator method.
+ * Runs a simple graph (one source and one sink component), calling the
+ * `on*()` methods of `runIn` along the way.
  */
-void runInMsgIterClsInit(RunInMsgIterClsInitFunc func);
+void runIn(RunIn& runIn);
 
-#endif /* TESTS_LIB_UTILS_H */
+#endif /* TESTS_LIB_UTILS_RUN_IN_HPP */
This page took 0.02663 seconds and 4 git commands to generate.