aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/lwtrace/custom_action.cpp
blob: dc97b44ac025b1932a17fb30961989421c828d3c (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; 
}