45void GlobalContext::make_handle(
ObjectId id, std::string
const &name,
48 ObjectRef so = m_node_local_context->make_shared(
51 m_local_objects[id] = std::move(so);
52 }
catch (Exception
const &) {
56void GlobalContext::remote_make_handle(
ObjectId id, std::string
const &name,
58 cb_make_handle(
id,
name,
pack(parameters));
61void GlobalContext::set_parameter(
ObjectId id, std::string
const &name,
64 m_local_objects.at(
id)->set_parameter(
name,
unpack(value, m_local_objects));
65 }
catch (Exception
const &) {
70 std::string
const &
name,
72 cb_set_parameter(ObjectId(o),
name,
pack(value));
75void GlobalContext::call_method(
ObjectId id, std::string
const &name,
78 m_local_objects.at(
id)->call_method(
name,
79 unpack(arguments, m_local_objects));
80 }
catch (Exception
const &) {
85 std::string
const &
name,
87 cb_call_method(ObjectId(o),
name,
pack(arguments));
90std::shared_ptr<ObjectHandle>
94 auto sp = m_node_local_context->factory().make(
name);
97 auto const id = ObjectId(sp.get());
98 remote_make_handle(
id,
name, parameters);
100 sp->construct(parameters);
102 return {sp.release(),
105 [global_context =
this, deleter = sp.get_deleter()](
ObjectHandle *o) {
113 global_context->cb_delete_handle(ObjectId(o));
125 return m_node_local_context->factory().type_name(*o);
Infrastructure to synchronize objects created on the head node with their corresponding remote copies...
void set_context(ObjectHandle *o)
Set the context of an object to this.
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.
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
Base class for interface handles.
std::vector< std::pair< std::string, PackedVariant > > PackedMap
std::shared_ptr< ObjectHandle > ObjectRef
make_recursive_variant< ObjectRef > Variant
Possible types for parameters.
PackedVariant pack(const Variant &v)
Transform a Variant to a PackedVariant.
make_recursive_variant< ObjectId > PackedVariant
Packed version of Variant.
std::unordered_map< std::string, Variant > VariantMap
Variant unpack(const PackedVariant &v, std::unordered_map< ObjectId, ObjectRef > const &objects)
Unpack a PackedVariant.
Strongly typed integer type to hold a unique identifier for a ObjectHandle object,...