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;
93 GlobalContext(std::shared_ptr<Communication::MpiCallbacks>
const &callbacks,
94 std::shared_ptr<LocalContext> node_local_context)
95 : m_local_objects(), m_node_local_context(
std::move(node_local_context)),
96 m_comm(callbacks->comm()), m_is_head_node(m_comm.rank() == 0),
98 m_parallel_exception_handler(m_comm),
99 cb_make_handle(callbacks,
100 [this](ObjectId id,
std::string const &
name,
102 make_handle(
id,
name, parameters);
104 cb_set_parameter(callbacks,
107 set_parameter(
id,
name, value);
109 cb_call_method(callbacks,
110 [
this](ObjectId
id, std::string
const &
name,
112 call_method(
id,
name, arguments);
114 cb_delete_handle(callbacks,
115 [
this](ObjectId
id) { delete_handle(
id); }) {}
121 void make_handle(ObjectId
id, std::string
const &
name,
130 void remote_make_handle(ObjectId
id, std::string
const &
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(ObjectHandle
const *o)
const override;
175 m_parallel_exception_handler.parallel_try_catch<std::exception>(cb);
177 boost::mpi::communicator
const &
get_comm()
const override {
return m_comm; }
ScriptInterface::Context decorates ScriptInterface::ObjectHandle objects with a context: a creation p...
Context of an object handle.
std::shared_ptr< ObjectHandle > make_shared(std::string const &name, VariantMap const ¶meters) override
Get a new reference counted instance of a script interface object by name.
boost::mpi::communicator const & get_comm() const override
GlobalContext(std::shared_ptr< Communication::MpiCallbacks > const &callbacks, std::shared_ptr< LocalContext > node_local_context)
void notify_call_method(ObjectHandle const *o, std::string const &name, VariantMap const &arguments) override
void notify_set_parameter(ObjectHandle const *o, std::string const &name, Variant const &value) override
bool is_head_node() const override
std::string_view name(ObjectHandle const *o) const override
void parallel_try_catch(std::function< void()> const &cb) const override