C++ Server-Side SDK
LaunchDarkly SDK
event_scope.hpp
1 #pragma once
2 
3 #include <launchdarkly/events/event_processor_interface.hpp>
4 
5 #include "event_factory.hpp"
6 
7 namespace launchdarkly::server_side {
8 
14 class EventScope {
15  public:
23  EventScope(events::IEventProcessor* processor, EventFactory factory)
24  : processor_(processor), factory_(std::move(factory)) {}
25 
29  EventScope() : EventScope(nullptr, EventFactory::WithoutReasons()) {}
30 
36  template <typename Callable>
37  void Send(Callable&& callable) const {
38  if (processor_) {
39  processor_->SendAsync(callable(factory_));
40  }
41  }
42 
43  private:
44  events::IEventProcessor* processor_;
45  EventFactory const factory_;
46 };
47 
48 } // namespace launchdarkly::server_side
Definition: event_factory.hpp:13
Definition: event_scope.hpp:14
void Send(Callable &&callable) const
Definition: event_scope.hpp:37
EventScope(events::IEventProcessor *processor, EventFactory factory)
Definition: event_scope.hpp:23
EventScope()
Definition: event_scope.hpp:29