MeshLib C++ Docs
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{
10
11
14template<class T>
16{
17public:
19 const std::optional<T> & get( const AffineXf3f & xf ) const
20 {
21 if ( cache_ && xf == xf_ )
22 return cache_;
23 static const std::optional<T> empty;
24 return empty;
25 }
27 void set( const AffineXf3f & xf, T t )
28 {
29 xf_ = xf;
30 cache_ = std::move( t );
31 }
33 void reset()
34 {
35 cache_.reset();
36 }
37
38private:
39 AffineXf3f xf_;
40 std::optional<T> cache_;
41};
42
43}
Definition MRXfBasedCache.h:16
void set(const AffineXf3f &xf, T t)
sets new transformation and the object
Definition MRXfBasedCache.h:27
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:19
void reset()
clears stored object
Definition MRXfBasedCache.h:33
only for bindings generation
Definition MRCameraOrientationPlugin.h:8