MeshLib C++ Docs
Loading...
Searching...
No Matches
MRCombinedHistoryAction.h
Go to the documentation of this file.
1#pragma once
2#include "MRMeshFwd.h"
3#include "MRHistoryAction.h"
4#include <memory>
5#include <optional>
6
7namespace MR
8{
11
12
16{
17public:
20 using DynamicNameGetter = std::function<std::string ()>;
21
23 MRMESH_API CombinedHistoryAction( const std::string& name, const std::vector<std::shared_ptr<HistoryAction>>& actions, const DynamicNameGetter& dynNameGetter = {} );
24
25 virtual std::string name() const override
26 {
27 return name_;
28 }
29
30 void setName( std::string name ) { name_ = std::move( name ); }
31
32 MRMESH_API virtual void action( HistoryAction::Type type ) override;
33
34 HistoryActionsVector& getStack() { return actions_; }
35 const HistoryActionsVector& getStack() const { return actions_; }
36
39 MRMESH_API bool filter( HistoryStackFilter filteringCondition );
40
41 bool empty() const { return actions_.empty(); };
42
44 MRMESH_API std::optional<std::string> getDynamicName() const;
45
46 [[nodiscard]] MRMESH_API virtual size_t heapBytes() const override;
47
48private:
49 HistoryActionsVector actions_;
50 std::string name_;
51 DynamicNameGetter dynNameGetter_;
52};
53
55MRMESH_API std::optional<std::string> getDynamicName( const std::shared_ptr<HistoryAction>& action );
56
57}
#define MRMESH_API
Definition MRMeshFwd.h:85
#define MRMESH_CLASS
Definition MRMeshFwd.h:92
bool empty() const
Definition MRCombinedHistoryAction.h:41
const HistoryActionsVector & getStack() const
Definition MRCombinedHistoryAction.h:35
virtual std::string name() const override
Definition MRCombinedHistoryAction.h:25
bool filter(HistoryStackFilter filteringCondition)
std::optional< std::string > getDynamicName() const
For actions with a dynamic name getter calls the getter and returns the dynamic name; otherwise retur...
virtual size_t heapBytes() const override
returns the amount of memory this object occupies on heap
std::function< std::string()> DynamicNameGetter
Definition MRCombinedHistoryAction.h:20
std::function< bool(const std::shared_ptr< HistoryAction > &)> HistoryStackFilter
Definition MRHistoryAction.h:38
std::vector< std::shared_ptr< HistoryAction > > HistoryActionsVector
Definition MRHistoryAction.h:39
HistoryActionsVector & getStack()
Definition MRCombinedHistoryAction.h:34
Type
Definition MRHistoryAction.h:27
virtual void action(HistoryAction::Type type) override
This function is called on history action (undo, redo, etc.)
void setName(std::string name)
Definition MRCombinedHistoryAction.h:30
HistoryAction()=default
explicitly define ctors to avoid warning C5267: definition of implicit copy constructor is deprecated...
CombinedHistoryAction(const std::string &name, const std::vector< std::shared_ptr< HistoryAction > > &actions, const DynamicNameGetter &dynNameGetter={})
Will call action() for each actions in given order (undo in reverse, redo in forward)
std::optional< std::string > getDynamicName(const std::shared_ptr< HistoryAction > &action)
Returns dynamic name if the action is an instance of CombinedHistoryAction; otherwise returns std::nu...
Only strictly necessary for the bindings (to make MR::MeshIntersectionResult a complete type).
Definition MRCameraOrientationPlugin.h:8