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 MRMESH_API virtual void action( HistoryAction::Type type ) override;
31
32 HistoryActionsVector& getStack() { return actions_; }
33 const HistoryActionsVector& getStack() const { return actions_; }
34
37 MRMESH_API bool filter( HistoryStackFilter filteringCondition );
38
39 bool empty() const { return actions_.empty(); };
40
42 MRMESH_API std::optional<std::string> getDynamicName() const;
43
44 [[nodiscard]] MRMESH_API virtual size_t heapBytes() const override;
45
46private:
47 HistoryActionsVector actions_;
48 std::string name_;
49 DynamicNameGetter dynNameGetter_;
50};
51
53MRMESH_API std::optional<std::string> getDynamicName( const std::shared_ptr<HistoryAction>& action );
54
55}
#define MRMESH_API
Definition MRMeshFwd.h:82
#define MRMESH_CLASS
Definition MRMeshFwd.h:89
bool empty() const
Definition MRCombinedHistoryAction.h:39
const HistoryActionsVector & getStack() const
Definition MRCombinedHistoryAction.h:33
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:32
Type
Definition MRHistoryAction.h:27
virtual void action(HistoryAction::Type type) override
This function is called on history action (undo, redo, etc.)
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 for bindings generation
Definition MRCameraOrientationPlugin.h:8