custom_action.cpp 639 B

123456789101112131415161718192021
  1. #include "custom_action.h"
  2. #include "control.h"
  3. using namespace NLWTrace;
  4. TCustomActionExecutor* TCustomActionFactory::Create(TProbe* probe, const TCustomAction& action, TSession* trace) const {
  5. auto iter = Callbacks.find(action.GetName());
  6. if (iter != Callbacks.end()) {
  7. return iter->second(probe, action, trace);
  8. } else {
  9. return nullptr;
  10. }
  11. }
  12. void TCustomActionFactory::Register(const TString& name, const TCustomActionFactory::TCallback& callback) {
  13. if (Callbacks.contains(name)) {
  14. ythrow yexception() << "duplicate custom action '" << name << "'";
  15. }
  16. Callbacks[name] = callback;
  17. }