Scarab  2.8.1
Project 8 C++ Utility Library
signal_handler_pybind.hh
Go to the documentation of this file.
1 #ifndef SIGNAL_HANDLER_PYBIND_HH_
2 #define SIGNAL_HANDLER_PYBIND_HH_
3 
4 #include "signal_handler.hh"
5 
6 #include "pybind11/pybind11.h"
7 
8 namespace scarab_pybind
9 {
10  std::list< std::string > export_signal_handler( pybind11::module& mod )
11  {
12  std::list< std::string > all_members;
13 
14  all_members.push_back( "cancel_all" );
15  mod.def( "cancel_all", [](int a_code){ return scarab::signal_handler::cancel_all( a_code ); },
17  "Asynchronous call to exit the process with the given exit code" );
18 
19  all_members.push_back( "SignalHandler" );
20  pybind11::class_< scarab::signal_handler >( mod, "SignalHandler", "handle system signals and pass cancel status to associated objects" )
21  .def( pybind11::init< >() )
22 
23  .def( "add_cancelable", &scarab::signal_handler::add_cancelable, "add a cancelable object to the list to be canceled in the event of a SIGINT" )
24  .def( "remove_cancelable", &scarab::signal_handler::remove_cancelable, "remove a cancelable object from the list to be canceled in the event of a SIGINT" )
25  .def( "reset", &scarab::signal_handler::reset, "remove all cancelable objects" )
26 
27  ;
28 
29  return all_members;
30  }
31 } /* namespace scarab_pybind */
32 #endif /* SIGNAL_HANDLER_PYBIND_HH_ */
std::list< std::string > export_signal_handler(pybind11::module &mod)
Wrapper for Python extension modules.
Definition: pybind11.h:789
static void cancel_all(int a_code)
Asynchronous call to exit the process with the given exit code.
void add_cancelable(cancelable *a_cancelable)
Add a cancelable object.
void remove_cancelable(cancelable *a_cancelable)
Remove a cancelable object.
void reset()
Remove all cancelables.
bool typename Extra class_ & def(const char *name_, Func &&f, const Extra &... extra)
Definition: pybind11.h:1110