aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/lwtrace/custom_action.cpp
blob: e8a2741c6aff596eee5963672d13abcdea6fad2a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include "custom_action.h"

#include "control.h"

using namespace NLWTrace;

TCustomActionExecutor* TCustomActionFactory::Create(TProbe* probe, const TCustomAction& action, TSession* trace) const {
    auto iter = Callbacks.find(action.GetName());
    if (iter != Callbacks.end()) {
        return iter->second(probe, action, trace);
    } else {
        return nullptr;
    }
}

void TCustomActionFactory::Register(const TString& name, const TCustomActionFactory::TCallback& callback) {
    if (Callbacks.contains(name)) { 
        ythrow yexception() << "duplicate custom action '" << name << "'";
    }
    Callbacks[name] = callback;
}