Loading...
Searching...
No Matches
pageCache.h
Go to the documentation of this file.
1//
2// Copyright 2025 Pixar
3//
4// Licensed under the terms set forth in the LICENSE.txt file available at
5// https://openusd.org/license.
6//
7#ifndef PXR_EXEC_EF_PAGE_CACHE_H
8#define PXR_EXEC_EF_PAGE_CACHE_H
9
11
12#include "pxr/pxr.h"
13
14#include "pxr/exec/ef/api.h"
17
18PXR_NAMESPACE_OPEN_SCOPE
19
29{
30public:
33 EF_API
35
42 template < typename T >
43 static Ef_PageCache *New() {
44 return new Ef_PageCache(&_KeyFactory<T>);
45 }
46
50 EF_API
51 Ef_OutputValueCache *Get(const VdfVector &key) const;
52
57 EF_API
59
62 EF_API
63 size_t Clear();
64
67 typedef
68 Ef_VectorKey::Map<Ef_OutputValueCache *>::Type
70
73 typedef
74 typename CacheMap::iterator
76
80 return _cache.begin();
81 }
82
86 return _cache.end();
87 }
88
89private:
90 // The type of the factory function, which is responsible for creating a
91 // Ef_VectorKey from a given VdfVector.
92 using _KeyFactoryFunction =
94
95 // Constructor.
96 EF_API
97 Ef_PageCache(_KeyFactoryFunction keyFactory);
98
99 // A factory functor, which creates an Ef_VectorKey (for use as a key in
100 // a hash map) from a VdfVector holding data of type T.
101 template < typename T >
102 static Ef_VectorKey::StoredType _KeyFactory(const VdfVector &value) {
104 }
105
106private:
107 // The map of pages to output-to-value caches.
108 CacheMap _cache;
109
110 // The key factory function for building new Ef_VectorKeys.
111 _KeyFactoryFunction _keyFactory;
112
113};
114
115PXR_NAMESPACE_CLOSE_SCOPE
116
117#endif
An output-to-value storage for caching.
Organizes output-to-value caches into logical groups, called pages.
Definition: pageCache.h:29
EF_API Ef_OutputValueCache * GetOrCreate(const VdfVector &key)
Get the output-to-value cache associated with the given key, or create a new, empty output-to-value c...
static Ef_PageCache * New()
Construct a new Ef_PageCache, which uses VdfVectors holding type T values as keys.
Definition: pageCache.h:43
Ef_VectorKey::Map< Ef_OutputValueCache * >::Type CacheMap
Type of the cache map.
Definition: pageCache.h:69
CacheMap::iterator iterator
Type of the cache map iterator.
Definition: pageCache.h:75
EF_API size_t Clear()
Clear the entire page cache.
iterator end()
Returns an iterator past the output-to-value cache in the last page.
Definition: pageCache.h:85
iterator begin()
Returns an iterator to the output-to-value cache in the first page.
Definition: pageCache.h:79
EF_API ~Ef_PageCache()
Destructor.
EF_API Ef_OutputValueCache * Get(const VdfVector &key) const
Get the output-to-value cache associated with the given key, if one exists.
The derived Ef_VectorKey type, which implements the methods for generating hashes and equality compar...
Definition: vectorKey.h:126
std::shared_ptr< Ef_VectorKey > StoredType
The type which must be used to store Ef_VectorKeys, for example as keys in a hash map.
Definition: vectorKey.h:41
This class is used to abstract away knowledge of the cache data used for each node.
Definition: vector.h:56