aboutsummaryrefslogtreecommitdiff
path: root/Source/Python/WarpX_py.cpp
blob: 49328d0a4a761cfae1f2face41cb06a35fd4226d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/* 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, 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 )
{
    return (warpx_callback_py_map.count(name) == 1u);
}

// Execute Python callbacks of the type given by the input string
void ExecutePythonCallback ( std::string 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);
}