42 using mapped_type = value_type;
43 using reference = mapped_type&;
44 using const_reference =
const mapped_type&;
45 using pointer = mapped_type*;
55 std::unique_lock lock01{ other.cacheMutex };
65 *
this = std::move(other);
72 template<
typename mapped_type_new> DCA_INLINE
auto emplace(mapped_type_new&&
object) {
74 return cacheMap.emplace(
makeUnique<std::remove_cvref_t<mapped_type_new>>(std::forward<mapped_type_new>(
object)));
81 template<
typename mapped_type_new> DCA_INLINE reference
operator[](mapped_type_new&& key) {
93 template<
typename mapped_type_new> DCA_INLINE
bool contains(mapped_type_new&& key) {
95 return cacheMap.contains(std::forward<mapped_type_new>(key));
101 template<
typename mapped_type_new> DCA_INLINE
void erase(mapped_type_new&& key) {
103 cacheMap.erase(std::forward<mapped_type_new>(key));
A template class representing an object cache.
DCA_INLINE bool contains(mapped_type_new &&key)
Check if the cache contains an object with a given key.
DCA_INLINE uint64_t count()
Get the number of objects currently in the cache.
DCA_INLINE ~object_cache()
Destructor for the object_cache class.
DCA_INLINE object_cache(object_cache &&other) noexcept
Move constructor for the object_cache class.
unordered_set< unique_ptr< mapped_type > > cacheMap
The underlying container for storing objects.
DCA_INLINE void erase(mapped_type_new &&key)
Remove an object from the cache using a key.
std::shared_mutex cacheMutex
Mutex for ensuring thread-safe access to the cache.
DCA_INLINE object_cache & operator=(object_cache &&other) noexcept
Move assignment operator for the object_cache class.
DCA_INLINE object_cache()
Default constructor for the object_cache class.
DCA_INLINE auto end()
Get an iterator to the end of the cache.
DCA_INLINE auto emplace(mapped_type_new &&object)
Add an object to the cache.
DCA_INLINE auto begin()
Get an iterator to the beginning of the cache.
DCA_INLINE reference operator[](mapped_type_new &&key)
Access an object in the cache using a key.
DCA_INLINE unique_ptr< value_type, deleter > makeUnique(arg_types &&... args)
Helper function to create a unique_ptr for a non-array object.
The main namespace for the forward-facing interfaces.