WaitGui(BatchExecutor *executor, std::chrono::milliseconds timeout, std::string name)
: PredicateWaitInterface(executor, timeout)
{
- if (name.empty()) {
+ {
auto h = self->contextInfo.lock();
- this->name = h->rootName;
+ this->currentContextName = h->rootName;
+ }
+ if (name.empty()) {
+ this->name = this->currentContextName;
searchForAnyChange = true;
} else {
this->name = std::move(name);
{
auto h = self->contextInfo.lock();
auto pred = [&]() {
+ if (currentContextName != h->rootName) {
+ self->outputStream() << "context name changed from '" << currentContextName << "', to '" << h->rootName << "'\n";
+ currentContextName = h->rootName;
+ }
return (searchForAnyChange && name != h->rootName) || (!searchForAnyChange && name == h->rootName);
};
if (pred()) return true;
return res;
}
- std::string name;
+ std::string name, currentContextName;
bool searchForAnyChange = false;
};
}
};
+DebugEvaluatorInterface *DebugEvaluatorInterface::getCurrentInterface()
+{
+ return debugInterface.get();
+}
+
void DebugEvaluatorInterface::setCurrentInterface(std::unique_ptr<DebugEvaluatorInterface> inf)
{
debugInterface = std::move(inf);
* set debug interface before launching any batch execution
*/
static void setCurrentInterface(std::unique_ptr<DebugEvaluatorInterface> inf = {});
+ static DebugEvaluatorInterface *getCurrentInterface();
+};
+
+class DebugEvaluator
+{
+ std::ostringstream tmp;
+public:
+ DebugEvaluator() = default;
+ ~DebugEvaluator()
+ {
+ auto v = DebugEvaluatorInterface::getCurrentInterface();
+ if (v) v->write(tmp.str());
+ }
+
+ template <typename T> DebugEvaluator &operator << (T &&t)
+ {
+ tmp << std::forward<T>(t);
+ return *this;
+ }
};
/**