MeshLib Documentation
Loading...
Searching...
No Matches
MRXfBasedCache.h
Go to the documentation of this file.
1#pragma once
2
3#include "MRAffineXf3.h"
4#include <optional>
5
6namespace MR
7{
8
11template<class T>
13{
14public:
16 const std::optional<T> & get( const AffineXf3f & xf ) const
17 {
18 if ( cache_ && xf == xf_ )
19 return cache_;
20 static const std::optional<T> empty;
21 return empty;
22 }
24 void set( const AffineXf3f & xf, T t )
25 {
26 xf_ = xf;
27 cache_ = std::move( t );
28 }
30 void reset()
31 {
32 cache_.reset();
33 }
34
35private:
36 AffineXf3f xf_;
37 std::optional<T> cache_;
38};
39
40} // namespace MR
Definition MRXfBasedCache.h:13
void set(const AffineXf3f &xf, T t)
sets new transformation and the object
Definition MRXfBasedCache.h:24
const std::optional< T > & get(const AffineXf3f &xf) const
returns stored object only if requested transformation is the same as stored one
Definition MRXfBasedCache.h:16
void reset()
clears stored object
Definition MRXfBasedCache.h:30
Definition MRCameraOrientationPlugin.h:8