<commit_before>/* This file is part of Om.  Copyright (C) 2006 <NAME>.
 * 
 * Om is free software; you can redistribute it and/or modify it under the
 * terms of the GNU General Public License as published by the Free Software
 * Foundation; either version 2 of the License, or (at your option) any later
 * version.
 * 
 * Om is distributed in the hope that it will be useful, but WITHOUT ANY
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for details.
 * 
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

#include "ObjectSender.h"
#include "interface/ClientInterface.h"
#include "Om.h"
#include "OmApp.h"
#include "ObjectStore.h"
#include "Patch.h"
#include "Node.h"
#include "Port.h"
#include "PortInfo.h"
#include "PortBase.h"
#include "Connection.h"
#include "NodeFactory.h"

namespace Om {

/** Send all currently existing objects to client.
 */
void
ObjectSender::send_all(ClientInterface* client)
{
	for (Tree<OmObject*>::iterator i = om->object_store()->objects().begin();
			i != om->object_store()->objects().end(); ++i)
		if ((*i)->as_patch() != NULL && (*i)->parent() == NULL)
			send_patch(client, (*i)->as_patch());
			//(*i)->as_node()->send_creation_messages(client);

}


void
ObjectSender::send_patch(ClientInterface* client, const Patch* patch)
{
	client->new_patch(patch->path(), patch->internal_poly());
	
	for (List<Node*>::const_iterator j = patch->nodes().begin();
			j != patch->nodes().end(); ++j) {
		const Node* const node = (*j);
		//const Port* const port = node->as_port(); // NULL unless a bridge node

		send_node(client, node);
		
		usleep(100);

		// If this is a bridge (input/output) node, send the patch control value as well
		//if (port && port->port_info()->is_control())
		//	client->control_change(port->path(),
		//		((PortBase<sample>*)port)->buffer(0)->value_at(0));
	}
	
	for (List<Connection*>::const_iterator j = patch->connections().begin();
			j != patch->connections().end(); ++j)
		client->connection((*j)->src_port()->path(), (*j)->dst_port()->path());
	
	// Send port information<commit_msg>Set cursor in on_map instead of on_show (which segfaults sometimes?)<commit_after>/* This file is part of Om.  Copyright (C) 2006 <NAME>.
 * 
 * Om is free software; you can redistribute it and/or modify it under the
 * terms of the GNU General Public License as published by the Free Software
 * Foundation; either version 2 of the License, or (at your option) any later
 * version.
 * 
 * Om is distributed in the hope that it will be useful, but WITHOUT ANY
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for details.
 * 
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

#include "ObjectSender.h"
#include "interface/ClientInterface.h"
#include "Om.h"
#include "OmApp.h"
#include "ObjectStore.h"
#include "Patch.h"
#include "Node.h"
#include "Port.h"
#include "PortInfo.h"
#include "PortBase.h"
#include "Connection.h"
#include "NodeFactory.h"

namespace Om {

/** Send all currently existing objects to client.
 */
void
ObjectSender::send_all(ClientInterface* client)
{
	for (Tree<OmObject*>::iterator i = om->object_store()->objects().begin();
			i != om->object_store()->objects().end(); ++i)
		if ((*i)->as_patch() != NULL && (*i)->parent() == NULL)
			send_patch(client, (*i)->as_patch());
			//(*i)->as_node()->send_creation_messages(client);

}


void
ObjectSender::send_patch(ClientInterface* client, const Patch* patch)
{
	client->new_patch(patch->path(), patch->internal_poly());
	
	for (List<Node*>::const_iterator j = patch->nodes().begin();
			j != patch->nodes().end(); ++j) {
		const Node* const node = (*j);

		send_node(client, node);
	}
	
	for (List<Connection*>::const_iterator j = patch->connections().begin();
			j != patch->connections().end(); ++j)
		client->connection((*j)->src_port()->path(), (*j)->dst_port()->path());
	
	// Send port information
{'fraction_non_alphanumeric': 0.15887635275155423, 'fraction_numerical': 0.009900990099009901, 'mean_word_length': 4.4232209737827715, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 61, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1763338', 'n_tokens_mistral': 1404, 'n_tokens_neox': 1302, 'n_words': 450}