void osc_controller::handle_add_node(world_node& obj)
{
    if (!m_skip) {
	int local_id(obj.get_id ());
	pair<int,int> net_id(m_id, local_id);

	m_local_id[net_id] = local_id;
	m_net_id[local_id] = net_id;

	lo_message msg = lo_message_new();

	lo_message_add_int32(msg, net_id.first);
	lo_message_add_int32(msg, net_id.second);
	lo_message_add_string(msg, obj.get_name().c_str());

	broadcast_message(PSYNTH_OSC_MSG_ADD, msg);

	lo_message_free(msg);
    }
}
void elem_toggler_component::handle_param_change (world_node& obj, int param_id)
{
    if (param_id == m_param_num) {
	destroy_toggles ();
	create_toggles ();
    } else if (param_id >= (int) m_param_first &&
	       param_id <= m_param_first + (int) m_toggles.size()) {
	int index = param_id - m_param_first;
	
	obj.get_param(param_id, m_toggles[index].second);
	if (m_step == index)
	    update_current_step_colour (index);
	else
	    update_step_colour (index);
    }
}
void osc_controller::handle_activate_node(world_node& obj)
{
    if (!m_skip) {
	int local_id(obj.get_id ());
	pair<int,int> net_id = m_net_id[local_id];

	lo_message msg = lo_message_new();

	lo_message_add_int32(msg, net_id.first);
	lo_message_add_int32(msg, net_id.second);

	broadcast_message(PSYNTH_OSC_MSG_ACTIVATE, msg);

	lo_message_free(msg);
    }
}
void osc_controller::handle_set_param_node(world_node& obj, int param_id)
{
    if (!m_skip) {
	int local_id(obj.get_id ());
	pair<int,int> net_id = m_net_id[local_id];

	lo_message msg = lo_message_new();

	lo_message_add_int32(msg, net_id.first);
	lo_message_add_int32(msg, net_id.second);
	lo_message_add_int32(msg, param_id);

	switch(obj.get_param_type(param_id)) {
	case graph::node_param::INT: {
	    int val;
	    obj.get_param(param_id, val);
	    lo_message_add_int32(msg, val);
	    break;
	}
	case graph::node_param::FLOAT: {
	    float val;
	    obj.get_param(param_id, val);
	    lo_message_add_float(msg, val);
	    break;
	}
	case graph::node_param::STRING: {
	    string val;
	    obj.get_param(param_id, val);
	    lo_message_add_string(msg, val.c_str());
	    break;
	}
	case graph::node_param::VECTOR2F: {
	    base::vector_2f val;
	    obj.get_param(param_id, val);
	    lo_message_add_float(msg, val.x);
	    lo_message_add_float(msg, val.y);
	    break;
	}
	default:
	    break;
	}

	broadcast_message(PSYNTH_OSC_MSG_PARAM, msg);

	lo_message_free(msg);
    }
}