MeshLib Documentation
Loading...
Searching...
No Matches
MRChangeValue.h
Go to the documentation of this file.
1#pragma once
2#include "MRHistoryAction.h"
3#include "MRAffineXf3.h"
4#include <memory>
5
6namespace MR
7{
8
14template <typename T>
16{
17public:
19 ChangeValue( const std::string& name, T* currentValue, T oldValue ) :
20 name_{ name },
21 currentValue_{ currentValue },
22 oldValue_{ oldValue }
23 {}
24
25 virtual std::string name() const override
26 {
27 return name_;
28 }
29
30 virtual void action( HistoryAction::Type ) override
31 {
32 if ( !currentValue_ )
33 return;
34 std::swap( *currentValue_, oldValue_ );
35 }
36
37 [[nodiscard]] virtual size_t heapBytes() const override
38 {
39 return name_.capacity();
40 }
41
42private:
43 std::string name_;
44 T* currentValue_ = nullptr;
45 T oldValue_;
46};
47
48}
Definition MRChangeValue.h:16
virtual void action(HistoryAction::Type) override
This function is called on history action (undo, redo, etc.)
Definition MRChangeValue.h:30
virtual std::string name() const override
Definition MRChangeValue.h:25
ChangeValue(const std::string &name, T *currentValue, T oldValue)
Constructed from original object's pointer and old value.
Definition MRChangeValue.h:19
virtual size_t heapBytes() const override
returns the amount of memory this object occupies on heap
Definition MRChangeValue.h:37
Definition MRHistoryAction.h:12
Type
Definition MRHistoryAction.h:19
Definition MRCameraOrientationPlugin.h:8