MeshLib C++ Docs
Loading...
Searching...
No Matches
MRChangeNameAction.h
Go to the documentation of this file.
1#pragma once
2
3#include "MRHistoryAction.h"
4#include "MRObject.h"
5#include <memory>
6#include <string>
7
8namespace MR
9{
10
13class ChangeNameAction : public HistoryAction
14{
15public:
17 ChangeNameAction( const std::string& actionName, std::shared_ptr<Object> obj ) :
18 obj_{ std::move( obj ) },
19 actionName_{ actionName }
20 {
21 objName_ = obj_->name();
22 }
23
24 virtual std::string name() const override
25 {
26 return actionName_;
27 }
28
29 virtual void action( HistoryAction::Type ) override
30 {
31 if ( !obj_ )
32 return;
33
34 auto n = obj_->name();
35 obj_->setName( std::move( objName_ ) );
36 objName_ = std::move( n );
37 }
38
39 [[nodiscard]] virtual size_t heapBytes() const override
40 {
41 return objName_.capacity() + actionName_.capacity();
42 }
43
44private:
45 std::shared_ptr<Object> obj_;
46 std::string objName_;
47
48 std::string actionName_;
49};
50
51} // namespace MR
unsafe ChangeNameAction(MR._ByValue_ChangeNameAction _other)
unsafe void action(MR.HistoryAction.Type _1)
Definition MRCameraOrientationPlugin.h:8