<commit_before>// Copyright 2019 <NAME>
#ifndef ARGCV_CXX_BASE_SIGNAL_SLOT_H_
#define ARGCV_CXX_BASE_SIGNAL_SLOT_H_

#include <cstdint>
#include <functional>
#include <map>
#include <utility>  // make_pair

#include "argcv/cxx/base/macros.h"

namespace argcv {

template <typename... Args>
class SignalSlot {
 public:
  typedef std::function<void(Args...)> Functor;

  SignalSlot() noexcept : top_id_(0) {}

  virtual ~SignalSlot() noexcept {}

  uint64_t Connect(Functor&& func) noexcept {
    uint64_t id = top_id_++;
    functors_.emplace(std::make_pair(id, func));
    return id;
  }

  bool Disconnect(uint64_t id) noexcept {
    if (functors_.find(id) != functors_.end()) {
      functors_.erase(id);
      // found
      return true;
    } else {
      // not exists
      return false;
    }
  }

  bool DisconnectAll() noexcept { functors_.clear(); }

  void Call(Args&&... args) noexcept {
    for (auto it : functors_) {
      it.second(args...);
    }
  }

 private:
  std::map<uint64_t, Functor> functors_;
  uint64_t top_id_;
};
}  // namespace argcv

#endif  // ARGCV_CXX_BASE_SIGNAL_SLOT_H_
<commit_msg>DISALLOW_COPY_AND_ASSIGN SignalSlot<commit_after>// Copyright 2019 <NAME>
#ifndef ARGCV_CXX_BASE_SIGNAL_SLOT_H_
#define ARGCV_CXX_BASE_SIGNAL_SLOT_H_

#include <cstdint>
#include <functional>
#include <map>
#include <utility>  // make_pair

#include "argcv/cxx/base/macros.h"

namespace argcv {

template <typename... Args>
class SignalSlot {
 public:
  typedef std::function<void(Args...)> Functor;

  SignalSlot() noexcept : top_id_(0) {}

  virtual ~SignalSlot() noexcept {}

  uint64_t Connect(Functor&& func) noexcept {
    uint64_t id = top_id_++;
    functors_.emplace(std::make_pair(id, func));
    return id;
  }

  bool Disconnect(uint64_t id) noexcept {
    if (functors_.find(id) != functors_.end()) {
      functors_.erase(id);
      // found
      return true;
    } else {
      // not exists
      return false;
    }
  }

  bool DisconnectAll() noexcept { functors_.clear(); }

  void Call(Args&&... args) noexcept {
    for (auto it : functors_) {
      it.second(args...);
    }
  }

 private:
  std::map<uint64_t, Functor> functors_;
  uint64_t top_id_;
  DISALLOW_COPY_AND_ASSIGN(SignalSlot);
};
}  // namespace argcv

#endif  // ARGCV_CXX_BASE_SIGNAL_SLOT_H_

{'fraction_non_alphanumeric': 0.13434782608695653, 'fraction_numerical': 0.013043478260869565, 'mean_word_length': 3.4165067178502877, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, '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': '6246554', 'n_tokens_mistral': 893, 'n_tokens_neox': 849, 'n_words': 174}