<commit_before>/*
 * Object.cpp
 *
 *  Created on: Mar 7, 2016
 *      Author: mad
 */

#include <vnl/Object.h>
#include <vnl/Pipe.h>
#include <vnl/Sample.h>
#include <vnl/Announce.hxx>
#include <vnl/LogMsg.hxx>
#include <vnl/Topic.hxx>
#include <vnl/Shutdown.hxx>
#include <vnl/Heartbeat.hxx>
#include <vnl/Exit.hxx>
#include <vnl/NoSuchMethodException.hxx>


namespace vnl {

void Object::exit() {
	vnl_dorun = false;
}

StringWriter Object::log(int level) {
	StringOutput* out = 0;
	if(level <= vnl_log_level) {
		vnl_log_writer.level = level;
		out = &vnl_log_writer;
	}
	return StringWriter(out);
}

Timer* Object::set_timeout(int64_t micros, const std::function<void()>& func, int type) {
	Timer& timer = *vnl_timers.push_back();
	timer.interval = micros;
	timer.func = func;
	timer.type = type;
	if(type != VNL_TIMER_MANUAL) {
		timer.reset();
	}
	return &timer;
}

void Object::add_client(Client& client, Router* target) {
	assert(vnl_dorun);
	client.connect(vnl_engine, target);
	vnl_output_channels[client.get_mac()] = "Client";
}

void Object::add_input(Stream& stream, Router* target) {
	assert(vnl_dorun);
	stream.connect(vnl_engine, target);
	stream.listen(this);
}

void Object::add_input(InputPin& pin) {
	assert(vnl_dorun);
	pin.enable(vnl_engine, this);
	vnl_input_pins[pin.get_mac()] = &pin;
}

void Object::add_output(OutputPin& pin) {
	assert(vnl_dorun);
	pin.enable(vnl_engine);
	vnl_output_pins[pin.get_mac()] = &pin;
}

Address Object::subscribe(const String& domain, const String& topic) {
	return subscribe(Address(domain, topic));
}

Address Object::subscribe(Address address) {
	return vnl_stream.subscribe(address);
}

void Object::unsubscribe(Hash64 domain, Hash64 topic) {
	unsubscribe(Address(domain, topic));
}
<commit_msg>add OutputPins also as output channels<commit_after>/*
 * Object.cpp
 *
 *  Created on: Mar 7, 2016
 *      Author: mad
 */

#include <vnl/Object.h>
#include <vnl/Pipe.h>
#include <vnl/Sample.h>
#include <vnl/Announce.hxx>
#include <vnl/LogMsg.hxx>
#include <vnl/Topic.hxx>
#include <vnl/Shutdown.hxx>
#include <vnl/Heartbeat.hxx>
#include <vnl/Exit.hxx>
#include <vnl/NoSuchMethodException.hxx>


namespace vnl {

void Object::exit() {
	vnl_dorun = false;
}

StringWriter Object::log(int level) {
	StringOutput* out = 0;
	if(level <= vnl_log_level) {
		vnl_log_writer.level = level;
		out = &vnl_log_writer;
	}
	return StringWriter(out);
}

Timer* Object::set_timeout(int64_t micros, const std::function<void()>& func, int type) {
	Timer& timer = *vnl_timers.push_back();
	timer.interval = micros;
	timer.func = func;
	timer.type = type;
	if(type != VNL_TIMER_MANUAL) {
		timer.reset();
	}
	return &timer;
}

void Object::add_client(Client& client, Router* target) {
	assert(vnl_dorun);
	client.connect(vnl_engine, target);
	vnl_output_channels[client.get_mac()] = "Client";
}

void Object::add_input(Stream& stream, Router* target) {
	assert(vnl_dorun);
	stream.connect(vnl_engine, target);
	stream.listen(this);
}

void Object::add_input(InputPin& pin) {
	assert(vnl_dorun);
	pin.enable(vnl_engine, this);
	vnl_input_pins[pin.get_mac()] = &pin;
}

void Object::add_output(OutputPin& pin) {
	assert(vnl_dorun);
	pin.enable(vnl_engine);
	vnl_output_pins[pin.get_mac()] = &pin;
	vnl_output_channels[pin.get_mac()] = "OutputPin";
}

Address Object::subscribe(const String& domain, const String& topic) {
	return subscribe(Address(domain, topic));
}

Address Object::subscribe(Address address) {
	return vnl_stream.subscribe(address);
}

void Object::unsubscribe(Hash64 domain, Hash64 topic) {
	unsubscribe(Address(domain, topic));
}

{'fraction_non_alphanumeric': 0.15412486064659978, 'fraction_numerical': 0.006688963210702341, 'mean_word_length': 5.634011090573013, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 25, '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': '3547483', 'n_tokens_mistral': 1438, 'n_tokens_neox': 1400, 'n_words': 261}