#define TESTS_LIB_CONDS_UTILS_HPP
#include <functional>
+#include <memory>
#include <string>
#include <utility>
+#include <vector>
#include <babeltrace2/babeltrace.h>
-#include "cpp-common/bt2s/optional.hpp"
+#include "cpp-common/bt2c/c-string-view.hpp"
#include "cpp-common/bt2s/span.hpp"
#include "../utils/run-in.hpp"
class CondTrigger
{
public:
+ using UP = std::unique_ptr<CondTrigger>;
+
/*
* Condition type.
*/
* name of the created condition trigger with name().
*/
explicit CondTrigger(Type type, const std::string& condId,
- const bt2s::optional<std::string>& nameSuffix) noexcept;
+ const bt2c::CStringView nameSuffix) noexcept;
public:
virtual ~CondTrigger() = default;
{
public:
explicit SimpleCondTrigger(std::function<void()> func, Type type, const std::string& condId,
- const bt2s::optional<std::string>& nameSuffix = bt2s::nullopt);
+ const bt2c::CStringView nameSuffix = {});
void operator()() noexcept override
{
{
public:
explicit RunInCondTrigger(RunInT runIn, const Type type, const std::string& condId,
- const bt2s::optional<std::string>& nameSuffix = bt2s::nullopt) :
+ const bt2c::CStringView nameSuffix = {}) :
CondTrigger {type, condId, nameSuffix},
_mRunIn {std::move(runIn)}
{
}
explicit RunInCondTrigger(const Type type, const std::string& condId,
- const bt2s::optional<std::string>& nameSuffix = bt2s::nullopt) :
+ const bt2c::CStringView nameSuffix = {}) :
RunInCondTrigger {RunInT {}, type, condId, nameSuffix}
{
}
/*
* List of condition triggers.
*/
-using CondTriggers = bt2s::span<CondTrigger * const>;
+using CondTriggers = std::vector<CondTrigger::UP>;
/*
* The entry point of a condition trigger program.
* The program is expected to abort through a libbabeltrace2
* condition failure.
*/
-void condMain(int argc, const char **argv, CondTriggers triggers) noexcept;
+void condMain(const bt2s::span<const char * const> argv, const CondTriggers& triggers) noexcept;
#endif /* TESTS_LIB_CONDS_UTILS_HPP */