#pragma once #include #include #include #include #include #include "warp.h" #include "binaryninjaapi.h" #include "uitypes.h" enum WarpFetchCompletionStatus { KeepCallback, RemoveCallback, }; // Responsible for fetching data from the containers, to later be queried from the container interface. class WarpFetcher { LoggerRef m_logger; std::mutex m_requestMutex; std::vector m_pendingRequests; std::unordered_set m_processedGuids; // List of callbacks to call when done fetching data, assume that others are using this as well. std::vector> m_completionCallbacks; public: explicit WarpFetcher(); // The global fetcher instance, this is used for the fetch dialog and the sidebar. static std::shared_ptr Global(); std::atomic m_requestInProgress = false; void AddCompletionCallback(std::function cb) { std::lock_guard lock(m_requestMutex); m_completionCallbacks.push_back(std::move(cb)); } void AddPendingFunction(const FunctionRef& func); void FetchPendingFunctions(const std::vector& allowedTags); void ClearProcessed(); private: std::vector FlushPendingFunctions(); void ExecuteCompletionCallback(); };