OSSIA
Open Scenario System for Interactive Application
opp::oscquery_mirror Class Reference

The oscquery_mirror class allows to create a mirror image of a remote OSCQuery server. More...

Detailed Description

The oscquery_mirror class allows to create a mirror image of a remote OSCQuery server.

Remote devices are mirror images of local devices on other applications: remote controls, mobile apps, etc. Every parameter in a local device will be synchronized with the remote devices that connected to it.

Public Member Functions

 oscquery_mirror (std::string name, std::string host="ws://127.0.0.1:5678")
 create an OSCQuery mirror device and connect it to a remote device More...
 
 ~oscquery_mirror ()
 OSCQuery Mirror default destructor.
 
node get_root_node () const
 get this server's root opp::node More...
 
void refresh ()
 refresh the Mirror's namespace More...
 
void update ()
 update mirror's namespace with changes since last update() call More...
 
void reconnect (std::string name="", std::string host="")
 reconnect to the remote device More...
 
bool is_connected () const
 is_connected More...
 
void set_parameter_created_callback (parameter_callback c, void *ctx)
 set a callback to be called when a parameter is created More...
 
void remove_parameter_created_callback ()
 remove the previously set parameter_callback
 
void set_parameter_removed_callback (parameter_callback c, void *ctx)
 set a callback to be called when a parameter is removed More...
 
void remove_parameter_removed_callback ()
 remove the previously set parameter_callback
 
void set_node_created_callback (node_callback c, void *ctx)
 set a callback to be called when a node is created More...
 
void remove_node_created_callback ()
 remove the previously set node_callback
 
void set_node_removed_callback (node_callback c, void *ctx)
 set a callback to be called when a node is removed More...
 
void remove_node_removed_callback ()
 remove the previously set node_callback
 
void set_node_renamed_callback (node_rn_callback c, void *ctx)
 set a callback to be called when a node is renamed More...
 
void remove_node_renamed_callback ()
 remove the previously set node_callback
 
void set_message_callback (message_callback c, void *ctx)
 set a callback to be called when a message is received More...
 
void remove_message_callback ()
 remove the previously set node_callback
 
void set_unhandled_message_callback (unhandled_message_callback c, void *ctx)
 set a callback to be called when an unhandled message is received More...
 
void remove_unhandled_message_callback ()
 remove the previously set node_callback
 
void set_attribute_modified_callback (attribute_modified_callback c, void *ctx)
 set a callback to be called when an attribute is modified More...
 
void remove_attribute_modified_callback ()
 remove the previously set node_callback
 
void set_zombie_on_remove (bool b)
 Set on removed behavior. More...
 
bool get_zombie_on_remove () const
 get_zombie_on_removed More...
 
void request_add_node (node parent, const std::string &name)
 request adding a node under the parent on the server with the given name More...
 
void request_remove_node (node node_to_be_removed)
 request removing the given node More...
 
void request_rename_node (node node, std::string new_name)
 request renaming of given node More...
 
ossia::net::device_baseget_raw_device_pointer ()
 Get the raw device pointer. More...
 

Constructor & Destructor Documentation

◆ oscquery_mirror()

opp::oscquery_mirror::oscquery_mirror ( std::string  name,
std::string  host = "ws://127.0.0.1:5678" 
)

create an OSCQuery mirror device and connect it to a remote device

It is possible to create a OSCQuery mirror and to connect it to a remote device.
This will allow to build a tree of opp::node s, the structure of which can be discovered by using get_root_node() and the opp::node::get_namespace(), opp::node::get_children() and opp::node::find_child() methods.
See the CPP98 tutorial example of the Documentation folder at the root of the libossia repository for an example of this.

Parameters
namethe name of the remote device (server)
hostthe IP of the remote device (server)

Member Function Documentation

◆ get_root_node()

node opp::oscquery_mirror::get_root_node ( ) const

get this server's root opp::node

Use get_root_node() in combination with opp::node::get_namespace(), opp::node::get_children() and opp::node::find_child() to build the mirror node tree.

Returns
this server's root opp::node

◆ refresh()

void opp::oscquery_mirror::refresh ( )

refresh the Mirror's namespace

Refresh the whole namespace, useful right after connecting This will deleta and recreate all nodes on mirror namespace.

◆ update()

void opp::oscquery_mirror::update ( )

update mirror's namespace with changes since last update() call

Apply the device's tree changes on the mirrored tree.

◆ reconnect()

void opp::oscquery_mirror::reconnect ( std::string  name = "",
std::string  host = "" 
)

reconnect to the remote device

When the connection the remote server we're mirroring has been lost, we need to reconnect to it in order to go on with the operations.

Parameters
namethe name of the remote device (server)
hostthe IP of the remote device (server)

◆ is_connected()

bool opp::oscquery_mirror::is_connected ( ) const
inline

is_connected

Returns
true if mirror is already connected

◆ set_parameter_created_callback()

void opp::oscquery_mirror::set_parameter_created_callback ( parameter_callback  c,
void *  ctx 
)

set a callback to be called when a parameter is created

Parameters
cthe parameter_callback
ctxthe callback context as a void*

◆ set_parameter_removed_callback()

void opp::oscquery_mirror::set_parameter_removed_callback ( parameter_callback  c,
void *  ctx 
)

set a callback to be called when a parameter is removed

Parameters
cthe parameter_callback
ctxthe callback context as a void*

◆ set_node_created_callback()

void opp::oscquery_mirror::set_node_created_callback ( node_callback  c,
void *  ctx 
)

set a callback to be called when a node is created

Parameters
cthe parameter_callback
ctxthe callback context as a void*

◆ set_node_removed_callback()

void opp::oscquery_mirror::set_node_removed_callback ( node_callback  c,
void *  ctx 
)

set a callback to be called when a node is removed

Parameters
cthe parameter_callback
ctxthe callback context as a void*

◆ set_node_renamed_callback()

void opp::oscquery_mirror::set_node_renamed_callback ( node_rn_callback  c,
void *  ctx 
)

set a callback to be called when a node is renamed

Parameters
cthe parameter_callback
ctxthe callback context as a void*

◆ set_message_callback()

void opp::oscquery_mirror::set_message_callback ( message_callback  c,
void *  ctx 
)

set a callback to be called when a message is received

Parameters
cthe parameter_callback
ctxthe callback context as a void*

◆ set_unhandled_message_callback()

void opp::oscquery_mirror::set_unhandled_message_callback ( unhandled_message_callback  c,
void *  ctx 
)

set a callback to be called when an unhandled message is received

Parameters
cthe parameter_callback
ctxthe callback context as a void*

◆ set_attribute_modified_callback()

void opp::oscquery_mirror::set_attribute_modified_callback ( attribute_modified_callback  c,
void *  ctx 
)

set a callback to be called when an attribute is modified

Parameters
cthe parameter_callback
ctxthe callback context as a void*

◆ set_zombie_on_remove()

void opp::oscquery_mirror::set_zombie_on_remove ( bool  b)

Set on removed behavior.

Parameters
mode: delete node when removed if false, mark it as zombie instead (default)

◆ get_zombie_on_remove()

bool opp::oscquery_mirror::get_zombie_on_remove ( ) const

get_zombie_on_removed

Returns

◆ request_add_node()

void opp::oscquery_mirror::request_add_node ( node  parent,
const std::string &  name 
)

request adding a node under the parent on the server with the given name

Parameters
parent
name

◆ request_remove_node()

void opp::oscquery_mirror::request_remove_node ( node  node_to_be_removed)

request removing the given node

Parameters
nodeto be removed

◆ request_rename_node()

void opp::oscquery_mirror::request_rename_node ( node  node,
std::string  new_name 
)

request renaming of given node

Parameters
nodeto be renamed
newname

◆ get_raw_device_pointer()

ossia::net::device_base* opp::oscquery_mirror::get_raw_device_pointer ( )
inline

Get the raw device pointer.

Be careful, this gives you great power and with great power comes... It's useful to make use of ossia feature that are not available in opp:: namespace (but requires some more computer skill)

Returns