7 #include <pybind11/pybind11.h> 9 typedef std::function< pybind11::module & (std::string const &) >
ModuleGetter;
11 void bind_std_exception(std::function< pybind11::module &(std::string
const &namespace_) > &M);
12 void bind_std_stdexcept(std::function< pybind11::module &(std::string
const &namespace_) > &M);
18 root_module.doc() =
"pymvsim_comms module";
20 std::map <std::string, pybind11::module> modules;
21 ModuleGetter M = [&](std::string
const &namespace_) -> pybind11::module & {
22 auto it = modules.find(namespace_);
23 if( it == modules.end() )
throw std::runtime_error(
"Attempt to access pybind11::module for namespace " + namespace_ +
" before it was created!!!");
27 modules[
""] = root_module;
29 std::vector< std::pair<std::string, std::string> > sub_modules {
33 for(
auto &
p : sub_modules ) modules[
p.first.size() ?
p.first+
"::"+
p.second :
p.second] = modules[
p.first].def_submodule(
p.second.c_str(), (
"Bindings for " +
p.first +
"::" +
p.second +
" namespace").c_str() );
void bind_mvsim_Comms_Client(std::function< pybind11::module &(std::string const &namespace_) > &M)
void bind_std_exception(std::function< pybind11::module &(std::string const &namespace_) > &M)
PYBIND11_MODULE(pymvsim_comms, root_module)
std::function< pybind11::module &(std::string const &) > ModuleGetter
void bind_mvsim_Comms_common(std::function< pybind11::module &(std::string const &namespace_) > &M)
void bind_std_stdexcept(std::function< pybind11::module &(std::string const &namespace_) > &M)