aboutsummaryrefslogtreecommitdiff
path: root/Source/Python/WarpX_py.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/Python/WarpX_py.cpp')
-rw-r--r--Source/Python/WarpX_py.cpp21
1 files changed, 16 insertions, 5 deletions
diff --git a/Source/Python/WarpX_py.cpp b/Source/Python/WarpX_py.cpp
index 7e0e491f8..49328d0a4 100644
--- a/Source/Python/WarpX_py.cpp
+++ b/Source/Python/WarpX_py.cpp
@@ -1,15 +1,21 @@
-/* Copyright 2019 David Grote, Maxence Thevenet, Weiqun Zhang
- *
+/* Copyright 2019-2022 The WarpX Community
*
* This file is part of WarpX.
*
+ * Authors: David Grote, Maxence Thevenet, Weiqun Zhang, Roelof Groenewald
+ *
* License: BSD-3-Clause-LBNL
*/
#include "WarpX_py.H"
-std::map< std::string, WARPX_CALLBACK_PY_FUNC_0 > warpx_callback_py_map;
+std::map< std::string, std::function<void()> > warpx_callback_py_map;
+
+void InstallPythonCallback ( std::string name, std::function<void()> callback )
+{
+ warpx_callback_py_map[name] = callback;
+}
-bool IsPythonCallBackInstalled ( std::string name )
+bool IsPythonCallbackInstalled ( std::string name )
{
return (warpx_callback_py_map.count(name) == 1u);
}
@@ -17,8 +23,13 @@ bool IsPythonCallBackInstalled ( std::string name )
// Execute Python callbacks of the type given by the input string
void ExecutePythonCallback ( std::string name )
{
- if ( IsPythonCallBackInstalled(name) ) {
+ if ( IsPythonCallbackInstalled(name) ) {
WARPX_PROFILE("warpx_py_"+name);
warpx_callback_py_map[name]();
}
}
+
+void ClearPythonCallback ( std::string name )
+{
+ warpx_callback_py_map.erase(name);
+}