![]() |
Dune-Fufem 2.11-git
|
A class for managing caches of different types. More...
#include <dune/fufem/forms/shapefunctioncache.hh>

Public Types | |
| using | QuadratureRule = Dune::QuadratureRule< CT, dimension > |
| using | size_type = std::size_t |
Public Member Functions | |
| CacheManager ()=default | |
| CacheManager (CacheManager &&other)=default | |
| CacheManager (const CacheManager &other)=default | |
| CacheManager & | operator= (const CacheManager &)=delete |
| CacheManager & | operator= (CacheManager &&)=delete |
| void | clear () |
| Clear all stored data. | |
| const QuadratureRule & | rule () const |
| Obtain the associated quadrature rule. | |
| void | setRule (const QuadratureRule &rule) |
| Set the associated quadrature rule for all stored caches. | |
| void | invalidate () |
| Invalidate all stores caches. | |
| void | report () const |
| template<class Cache > | |
| size_type | registerCache (UniqueCacheId uniqueCacheId, Cache &&cache) |
| Register a new cache. | |
| template<class Cache > | |
| auto & | getCache (size_type index) |
| Obtain a registered cache. | |
Detailed Description
class Dune::Fufem::Forms::CacheManager< CT, dimension >
A class for managing caches of different types.
This class can store a collection of caches of different type using type erasure. Each stored cache is identified using a UniqueCacheId. A cache object is stored in the CacheManager by calling cacheManager.registerCache(uniqueCacheId, cache). Later calls with the same uniqueCacheId will not store a new instance but reuse the existing one.
While registering the caches is in general not critical, requesting existing caches happens inside of local loops. Thus this class is optimized for fast retrieval of stored caches. To avoid a map lookup, all caches are stored in a plain vector and accessed by an index. The index of the newly stored or reused cache is returned by the registerCache() method.
A stored cache can be queried using cacheManager.getCache<Cache>(index). Notice that the template parameter is needed in order to cast the type-erased stored cache to the actual implementation class type.
This class provides the interface of a cache itself and is designed for being stored inside of a MultipleQuadratureCache. It is especially copy-constructible. Copying a CacheManager will create copies of all stored caches preserving the exact erased type and indices. Thus the following is guaranteed to work (and actually the intended usage): Register caches in one CacheManager A and store the obtained indices. Create a copy B of A. Set a different QuadratureRule for B. Obtain caches from B with the indices obtained while registering in A.
Member Typedef Documentation
◆ QuadratureRule
| using Dune::Fufem::Forms::CacheManager< CT, dimension >::QuadratureRule = Dune::QuadratureRule<CT, dimension> |
◆ size_type
| using Dune::Fufem::Forms::CacheManager< CT, dimension >::size_type = std::size_t |
Constructor & Destructor Documentation
◆ CacheManager() [1/3]
|
default |
◆ CacheManager() [2/3]
|
default |
◆ CacheManager() [3/3]
|
default |
Member Function Documentation
◆ clear()
|
inline |
Clear all stored data.
◆ getCache()
|
inline |
Obtain a registered cache.
- Template Parameters
-
Cache Type of the stored cache
- Parameters
-
index Index of the stored cache as returned by registerCache()
- Returns
- The cache stored under the given index casted to the provided type.
Using a Cache type other than the one used when storing the cache is undefined behaviour.
◆ invalidate()
|
inline |
Invalidate all stores caches.
◆ operator=() [1/2]
|
delete |
◆ operator=() [2/2]
|
delete |
◆ registerCache()
|
inline |
Register a new cache.
- Parameters
-
uniqueCacheId Unique identifier of the cache to be registered cache Cache to be registered
- Returns
- Index of the stored cache
If there is no cache registered with the provided uniqueCacheId, this will store a copy of the provided cache under the id. If there Otherwise the already stored cache is reused and the provided argument is ignored. In any case the returned index can be used to obtain the cache later.
◆ report()
|
inline |
◆ rule()
|
inline |
Obtain the associated quadrature rule.
◆ setRule()
|
inline |
Set the associated quadrature rule for all stored caches.
The documentation for this class was generated from the following file:
