MeshLib C++ Docs
Loading...
Searching...
No Matches
MRPythonAppendCommand.h
Go to the documentation of this file.
1#pragma once
2#include "MRCommandLoop.h"
3
4namespace MR
5{
8
9
12template<typename F, typename... Args>
13void pythonAppendOrRun( F func, Args&&... args )
14{
15 auto deferredAction = [funcLocal = std::move( func ), &...argsLocal = args]() mutable
16 {
17 funcLocal( std::forward<Args>( argsLocal )... );
18 };
19 MR::CommandLoop::runCommandFromGUIThread( std::move( deferredAction ) );
20}
21
25template<typename R, typename... Args>
26[[nodiscard]] auto pythonRunFromGUIThread( std::function<R( Args... )>&& f ) -> std::function<void( Args... )>
27{
28 return[fLocal = std::move( f )]( Args&&... args ) mutable
29 {
31 pythonAppendOrRun( fLocal, std::forward<Args>( args )... );
32 };
33}
34
35template<typename F>
36[[nodiscard]] auto pythonRunFromGUIThread( F&& f )
37{
38 return pythonRunFromGUIThread( std::function( std::forward<F>( f ) ) );
39}
40
41template<typename R, typename T, typename... Args>
42auto pythonRunFromGUIThread( R( T::* memFunction )( Args... ) )
43{
44 return pythonRunFromGUIThread( std::function<R( T*, Args... )>( std::mem_fn( memFunction ) ) );
45}
46
47}
auto pythonRunFromGUIThread(std::function< R(Args...)> &&f) -> std::function< void(Args...)>
Definition MRPythonAppendCommand.h:26
static MRVIEWER_API void runCommandFromGUIThread(CommandFunc func)
void pythonAppendOrRun(F func, Args &&... args)
Definition MRPythonAppendCommand.h:13
only for bindings generation
Definition MRCameraOrientationPlugin.h:8