65 bool add_processor(
const std::shared_ptr<BufferProcessor>& processor,
const std::shared_ptr<Buffer>& buffer, std::string* rejection_reason =
nullptr);
79 void remove_processor(
const std::shared_ptr<BufferProcessor>& processor,
const std::shared_ptr<Buffer>& buffer);
96 void process(
const std::shared_ptr<Buffer>& buffer);
108 void add_final_processor(
const std::shared_ptr<BufferProcessor>& processor,
const std::shared_ptr<Buffer>& buffer);
118 bool has_processors(
const std::shared_ptr<Buffer>& buffer)
const;
129 const std::vector<std::shared_ptr<BufferProcessor>>& get_processors(
const std::shared_ptr<Buffer>& buffer)
const;
139 inline std::unordered_map<std::shared_ptr<Buffer>, std::vector<std::shared_ptr<BufferProcessor>>>
get_chain()
const {
return m_buffer_processors; }
154 void merge_chain(
const std::shared_ptr<BufferProcessingChain>& other);
165 void process_final(
const std::shared_ptr<Buffer>& buffer);
187 return m_token_filter_mask;
200 m_enforcement_strategy = strategy;
213 return m_enforcement_strategy;
227 void optimize_for_tokens(
const std::shared_ptr<Buffer>& buffer);
238 std::vector<TokenCompatibilityReport> analyze_token_compatibility()
const;
248 bool validate_all_processors(std::vector<std::string>* incompatibility_reasons =
nullptr)
const;
258 void enforce_chain_token_on_processors();
262 return m_pending_count.load(std::memory_order_relaxed) > 0;
275 template <
typename T>
276 std::shared_ptr<T>
get_processor(
const std::shared_ptr<Buffer>& buffer)
const
278 auto processors = get_processors(buffer);
280 for (
auto& processor : processors) {
281 if (
auto t_processor = std::dynamic_pointer_cast<T>(processor)) {
289 bool add_processor_direct(
const std::shared_ptr<BufferProcessor>& processor,
const std::shared_ptr<Buffer>& buffer, std::string* rejection_reason =
nullptr);
290 void remove_processor_direct(
const std::shared_ptr<BufferProcessor>& processor,
const std::shared_ptr<Buffer>& buffer);
302 void process_non_owning(
const std::shared_ptr<Buffer>& buffer);
307 void cleanup_rejected_processors(
const std::shared_ptr<Buffer>& buffer);
312 void process_pending_processor_operations();
314 bool queue_pending_processor_op(
const std::shared_ptr<BufferProcessor>& processor,
const std::shared_ptr<Buffer>& buffer,
bool is_addition, std::string* rejection_reason =
nullptr);
323 std::unordered_map<std::shared_ptr<Buffer>, std::vector<std::shared_ptr<BufferProcessor>>>
m_buffer_processors;
333 std::unordered_map<std::shared_ptr<Buffer>, std::unordered_set<std::shared_ptr<BufferProcessor>>>
m_pending_removal;
362 static constexpr size_t MAX_PENDING_PROCESSORS = 32;
365 std::atomic<bool> active {
false };
368 bool is_addition {
true };
375 std::atomic<uint32_t> m_pending_count { 0 };
void add_processor(const std::shared_ptr< Buffers::BufferProcessor > &processor, const std::shared_ptr< Buffers::Buffer > &buffer, Buffers::ProcessingToken token)
Adds a processor to a specific buffer.