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{
12
13
17{
18public:
20 ChangeNameAction( const std::string& actionName, std::shared_ptr<Object> obj ) :
21 obj_{ std::move( obj ) },
22 actionName_{ actionName }
23 {
24 objName_ = obj_->name();
25 }
26
27 virtual std::string name() const override
28 {
29 return actionName_;
30 }
31
32 virtual void action( HistoryAction::Type ) override
33 {
34 if ( !obj_ )
35 return;
36
37 auto n = obj_->name();
38 obj_->setName( std::move( objName_ ) );
39 objName_ = std::move( n );
40 }
41
42 [[nodiscard]] virtual size_t heapBytes() const override
43 {
44 return objName_.capacity() + actionName_.capacity();
45 }
46
47private:
48 std::shared_ptr<Object> obj_;
49 std::string objName_;
50
51 std::string actionName_;
52};
53
54}
Definition MRChangeNameAction.h:17
Definition MRHistoryAction.h:15
virtual void action(HistoryAction::Type) override
This function is called on history action (undo, redo, etc.)
Definition MRChangeNameAction.h:32
virtual size_t heapBytes() const override
returns the amount of memory this object occupies on heap
Definition MRChangeNameAction.h:42
ChangeNameAction(const std::string &actionName, std::shared_ptr< Object > obj)
construct before giving new name to the object
Definition MRChangeNameAction.h:20
Type
Definition MRHistoryAction.h:22
virtual std::string name() const override
Definition MRChangeNameAction.h:27
only for bindings generation
Definition MRCameraOrientationPlugin.h:8