X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=blobdiff_plain;f=tests%2Flib%2Futils%2Frun-in.hpp;fp=tests%2Flib%2Futils%2Frun-in.hpp;h=d08e931a125cb8e67719ec8765c389b49f405a99;hp=01774f9053f5e424dcea154d84b31d73f3f955c2;hb=5d7e57e846a27172cc3bc5d0fcf5b3e55551e289;hpb=0133a2ba3063b5b8526990bf95f2f53ed212f6a6 diff --git a/tests/lib/utils/run-in.hpp b/tests/lib/utils/run-in.hpp index 01774f90..d08e931a 100644 --- a/tests/lib/utils/run-in.hpp +++ b/tests/lib/utils/run-in.hpp @@ -7,46 +7,43 @@ #ifndef TESTS_LIB_UTILS_H #define TESTS_LIB_UTILS_H -#include - #include #include "cpp-common/bt2/self-component-class.hpp" #include "cpp-common/bt2/self-component-port.hpp" #include "cpp-common/bt2/self-message-iterator.hpp" -using RunInCompClsQueryFunc = std::function; -using RunInCompClsInitFunc = std::function; -using RunInMsgIterClsInitFunc = std::function; - /* - * 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 */