41#include <boost/mpi/communicator.hpp>
42#include <boost/serialization/utility.hpp>
49#include <unordered_map>
72 std::unordered_map<ObjectId, ObjectRef> m_local_objects;
74 std::shared_ptr<LocalContext> m_node_local_context;
76 boost::mpi::communicator
const &m_comm;
96 m_comm(
callbacks->comm()), m_is_head_node(m_comm.rank() == 0),
98 m_parallel_exception_handler(m_comm),
107 set_parameter(
id,
name, value);
110 [
this](ObjectId
id, std::string
const &
name,
115 [
this](ObjectId
id) { delete_handle(
id); }) {}
121 void make_handle(ObjectId
id,
const std::string &
name,
130 void remote_make_handle(ObjectId
id,
const std::string &
name,
137 void set_parameter(ObjectId
id, std::string
const &
name,
142 Variant const &value)
override;
148 void call_method(ObjectId
id, std::string
const &
name,
159 void delete_handle(ObjectId
id) { m_local_objects.erase(
id); }
168 std::shared_ptr<ObjectHandle>
171 std::string_view
name(
const ObjectHandle *
o)
const override;
177 boost::mpi::communicator
const &
get_comm()
const override {
return m_comm; }
ScriptInterface::Context decorates ScriptInterface::ObjectHandle objects with a context: a creation p...
Communication::MpiCallbacks manages MPI communication using a visitor pattern.
RAII handle for a callback.
Context of an object handle.
Global synchronizing context.
std::shared_ptr< ObjectHandle > make_shared(std::string const &name, const VariantMap ¶meters) override
Get a new reference counted instance of a script interface object by name.
void notify_set_parameter(const ObjectHandle *o, std::string const &name, Variant const &value) override
boost::mpi::communicator const & get_comm() const override
std::string_view name(const ObjectHandle *o) const override
GlobalContext(std::shared_ptr< Communication::MpiCallbacks > const &callbacks, std::shared_ptr< LocalContext > node_local_context)
bool is_head_node() const override
void parallel_try_catch(std::function< void()> const &cb) const override
void notify_call_method(const ObjectHandle *o, std::string const &name, VariantMap const &arguments) override
Handle exceptions thrown in MPI parallel code.
void parallel_try_catch(std::function< void()> const &callback) const
Handle exceptions in synchronous code.
make_recursive_variant< ObjectId > PackedVariant
Packed version of Variant.
T get_value(Variant const &v)
Extract value of specific type T from a Variant.
std::unordered_map< std::string, Variant > VariantMap
std::vector< std::pair< std::string, PackedVariant > > PackedMap
make_recursive_variant< ObjectRef > Variant
Possible types for parameters.
Strongly typed integer type to hold a unique identifier for a ObjectHandle object,...
Recursive variant implementation.