<commit_before>/*
 * Copyright (c) 2014, webvariants GmbH, http://www.webvariants.de
 *
 * This file is released under the terms of the MIT license. You can find the
 * complete text in the attached LICENSE file or online at:
 *
 * http://www.opensource.org/licenses/mit-license.php
 *
 * @author: <NAME> (<EMAIL>), <NAME> (<EMAIL>)
 */


#ifndef __CPPENGINE_ENGINE__
#define __CPPENGINE_ENGINE__

#include <memory>
#include <map>

#include "apiserver/ApiClient.h"
#include "BaseController.h"

namespace Susi {
namespace Cpp {


class Engine {
protected:

	std::shared_ptr<Susi::Api::ApiClient> susi_api;

	std::map<std::string, std::shared_ptr<Susi::Cpp::BaseController>> controller;

	void addController(std::string name, Susi::Cpp::BaseController *c) {
		controller[name] = std::shared_ptr<Susi::Cpp::BaseController>{c};
		controller[name]->setApi(susi_api);
	}


public:
	Engine(std::string address = "[::1]:4000") : susi_api{ new Susi::Api::ApiClient{address}} {
		susi_api->subscribe(std::string{"heartbeat::minute",Susi::Events::Consumer{[&susi_api](){
			auto event = susi_api->createEvent("session::update");
			susi_api->publish(std::move(event));
		}}});
	}
	void populateController();

	std::shared_ptr<Susi::Api::ApiClient> getApi() {
		return susi_api;
	}

	void start() {
		for(auto & kv : controller){
			kv.second->start();
		}
	}

	void stop() {
		for(auto & kv : controller){
			kv.second->stop();
		}
	}<commit_msg>[cppengine] fixed reference error;<commit_after>/*
 * Copyright (c) 2014, webvariants GmbH, http://www.webvariants.de
 *
 * This file is released under the terms of the MIT license. You can find the
 * complete text in the attached LICENSE file or online at:
 *
 * http://www.opensource.org/licenses/mit-license.php
 *
 * @author: <NAME> (<EMAIL>), <NAME> (<EMAIL>)
 */


#ifndef __CPPENGINE_ENGINE__
#define __CPPENGINE_ENGINE__

#include <memory>
#include <map>

#include "apiserver/ApiClient.h"
#include "BaseController.h"

namespace Susi {
namespace Cpp {


class Engine {
protected:

	std::shared_ptr<Susi::Api::ApiClient> susi_api;

	std::map<std::string, std::shared_ptr<Susi::Cpp::BaseController>> controller;

	void addController(std::string name, Susi::Cpp::BaseController *c) {
		controller[name] = std::shared_ptr<Susi::Cpp::BaseController>{c};
		controller[name]->setApi(susi_api);
	}


public:
	Engine(std::string address = "[::1]:4000") : susi_api{ new Susi::Api::ApiClient{address}} {
		susi_api->subscribe(std::string{"heartbeat::minute",Susi::Events::Consumer{[this](){
			auto event = susi_api->createEvent("session::update");
			susi_api->publish(std::move(event));
		}}});
	}
	void populateController();

	std::shared_ptr<Susi::Api::ApiClient> getApi() {
		return susi_api;
	}

	void start() {
		for(auto & kv : controller){
			kv.second->start();
		}
	}

	void stop() {
		for(auto & kv : controller){
			kv.second->stop();
		}
	}
{'fraction_non_alphanumeric': 0.17186417186417186, 'fraction_numerical': 0.006237006237006237, 'mean_word_length': 5.359030837004405, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 37, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, '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': '7232473', 'n_tokens_mistral': 1107, 'n_tokens_neox': 1006, 'n_words': 203}