22#ifndef CIRCUIT_CACHE_CPP_H
23#define CIRCUIT_CACHE_CPP_H
31#include <boost/multi_index_container.hpp>
32#include <boost/multi_index/hashed_index.hpp>
33#include <boost/multi_index/member.hpp>
34#include <boost/multi_index/sequenced_index.hpp>
36using namespace boost::multi_index;
58 inline unsigned size()
const {
78typedef multi_index_container<
82 hashed_unique<member<CircuitCacheInfos, pg_uuid_t, &CircuitCacheInfos::token> >
122std::optional<CircuitCacheInfos>
get(
pg_uuid_t token)
const;
CircuitCache()
Construct an empty cache.
multi_index_container< CircuitCacheInfos, indexed_by< sequenced<>, hashed_unique< member< CircuitCacheInfos, pg_uuid_t, &CircuitCacheInfos::token > > > > item_list
Boost multi-index container type for cache entries.
item_list il
The container holding cached entries.
item_list::iterator iterator
Iterator type for iterating over cache entries in FIFO order.
unsigned current_size
Current total byte usage of cached entries.
CircuitCacheInfos item_type
The value type stored in the cache.
iterator end()
Past-the-end iterator for the cache.
iterator begin()
Iterator to the first cached entry (oldest).
bool insert(const CircuitCacheInfos &infos)
Insert a new gate into the cache, evicting the oldest if necessary.
std::optional< CircuitCacheInfos > get(pg_uuid_t token) const
Look up a gate by UUID.
C++ utility functions for UUID manipulation.
All information stored for a single gate in the circuit cache.
std::vector< pg_uuid_t > children
Ordered list of child gate UUIDs.
unsigned size() const
Estimated memory footprint of this entry in bytes.
gate_type type
Kind of gate (input, plus, times, …).
pg_uuid_t token
UUID identifying this gate.