24#ifndef FBCPP_EVENT_LISTENER_H 
   25#define FBCPP_EVENT_LISTENER_H 
   27#include "Attachment.h" 
   32#include <condition_variable> 
   72        using Callback = std::function<void(
const std::vector<EventCount>& counts)>;
 
   75        class FirebirdCallback final : 
public fb::IEventCallbackImpl<FirebirdCallback, impl::StatusWrapper>
 
   83            void eventCallbackFunction(
unsigned length, 
const std::uint8_t* events)
 override 
   86                    owner->handleEvent(length, events);
 
   89            void addRef()
 override 
   94            int release()
 override 
  100            void detach() 
noexcept 
  148        void handleEvent(
unsigned length, const std::uint8_t* events);
 
  150        void cancelEventsHandle();
 
  151        void decodeEventCounts();
 
  156        std::vector<std::
string> eventNames;
 
  158        FbRef<fb::IEvents> eventsHandle;
 
  159        FirebirdCallback firebirdCallback;
 
  160        std::vector<std::uint8_t> eventBuffer;
 
  161        std::vector<std::uint8_t> resultBuffer;
 
  162        std::vector<std::uint32_t> rawCounts;
 
  163        std::vector<
unsigned> countOffsets;
 
  164        std::deque<std::vector<
EventCount>> pendingNotifications;
 
  165        std::thread dispatcher;
 
  167        std::condition_variable condition;
 
  168        bool listening = false;
 
  169        bool running = false;
 
 
Represents a connection to a Firebird database.
Represents a Firebird client library instance.
Observes Firebird events and forwards aggregated counts to a callback on a background thread.
bool isListening() noexcept
Returns true if the listener is currently registered for event notifications.
~EventListener() noexcept
Stops the listener and waits for any background work to finish.
void stop()
Cancels event notifications and releases related resources.
std::function< void(const std::vector< EventCount > &counts)> Callback
Function invoked when new event counts are available.
Represents the number of occurrences for a registered event delivered by Firebird.
std::string name
Name of the event reported by the database.
unsigned count
Number of times the event fired since the last notification.