<commit_before>#ifndef __DARC_COMPONENT_H_INCLUDED__
#define __DARC_COMPONENT_H_INCLUDED__

#include <boost/asio.hpp>
#include <boost/bind.hpp>
#include <darc/node.h>
#include <darc/owner.h>

namespace darc
{

class Component : public Owner
{
public:
  typedef boost::shared_ptr<Component> Ptr;

protected:
  std::string name_;
  boost::shared_ptr<Node> node_;
  boost::asio::io_service io_service_;

protected:
  Component(const std::string& name, boost::shared_ptr<Node> node):
    name_(name),
    node_( node )
  {
  }

public:
  // impl of darc::Owner
  boost::asio::io_service * getIOService()
  {
    return &io_service_;
  }

  // impl of darc::Owner
  boost::shared_ptr<Node> getNode()
  {
    return node_;
  }

  template<typename T>
  static boost::shared_ptr<T> instantiate( const std::string& instance_name, Node::Ptr node )
  {
    boost::shared_ptr<T> instance( new T(instance_name, node) );
    return instance;
  }

public:
  const std::string& getName() const
  {
    return name_;
  }

  void run()
  {
    std::cout << "Running Component: " << name_ << std::endl;
    io_service_.run();
  }

};

}

// Include here so its available for the components
#include <darc/component_register.h>

#endif<commit_msg>keep io_service alive<commit_after>#ifndef __DARC_COMPONENT_H_INCLUDED__
#define __DARC_COMPONENT_H_INCLUDED__

#include <boost/asio.hpp>
#include <boost/bind.hpp>
#include <darc/node.h>
#include <darc/owner.h>

namespace darc
{

class Component : public Owner
{
public:
  typedef boost::shared_ptr<Component> Ptr;

protected:
  std::string name_;
  boost::shared_ptr<Node> node_;
  boost::asio::io_service io_service_;

protected:
  Component(const std::string& name, boost::shared_ptr<Node> node):
    name_(name),
    node_( node )
  {
  }

public:
  // impl of darc::Owner
  boost::asio::io_service * getIOService()
  {
    return &io_service_;
  }

  // impl of darc::Owner
  boost::shared_ptr<Node> getNode()
  {
    return node_;
  }

  template<typename T>
  static boost::shared_ptr<T> instantiate( const std::string& instance_name, Node::Ptr node )
  {
    boost::shared_ptr<T> instance( new T(instance_name, node) );
    return instance;
  }

public:
  const std::string& getName() const
  {
    return name_;
  }

  void run()
  {
    std::cout << "Running Component: " << name_ << std::endl;
    boost::asio::io_service::work keep_alive(io_service_);
    io_service_.run();
    std::cout << "Component " << name_ << " Stopped!" << std::endl;
  }

};

}

// Include here so its available for the components
#include <darc/component_register.h>

#endif
{'fraction_non_alphanumeric': 0.13778463913546893, 'fraction_numerical': 0.0, 'mean_word_length': 4.142857142857143, 'pattern_counts': {'":': 0, '<': 47, '<?xml version=': 0, '>': 27, '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': '2193081', 'n_tokens_mistral': 942, 'n_tokens_neox': 920, 'n_words': 200}