<commit_before><commit_msg>Added abstract class for Capture modules.<commit_after>/*
 * capture.h
 * Copyright (C) 2014 xent
 * Project is distributed under the terms of the GNU General Public License v3.0
 */

#ifndef CAPTURE_H_
#define CAPTURE_H_
/*----------------------------------------------------------------------------*/
#include <stdbool.h>
#include <stdint.h>
#include <entity.h>
#include <pin.h>
/*----------------------------------------------------------------------------*/
/* Class descriptor */
struct CaptureClass
{
  CLASS_HEADER

  void (*callback)(void *, void (*)(void *), void *);
  void (*setEnabled)(void *, bool);
  uint32_t (*value)(const void *);
};
/*----------------------------------------------------------------------------*/
struct Capture
{
  struct Entity parent;
};
/*----------------------------------------------------------------------------*/
/**
 * Set callback function for capture event.
 * @param capture Pointer to a Capture object.
 * @param callback Callback function.
 * @param argument Callback function argument.
 */
static inline void captureCallback(void *capture, void (*callback)(void *),
    void *argument)
{
  ((const struct CaptureClass *)CLASS(capture))->callback(capture, callback,
      argument);
}
/*----------------------------------------------------------------------------*/
/**
 * Start or stop event capture.
 * @param capture Pointer to a Capture object.
 * @param state Capture state: @b true to enable or @b false to disable.
 */
static inline void captureSetEnabled(void *capture, bool state)
{
  ((const struct CaptureClass *)CLASS(capture))->setEnabled(capture, state);
}
/*----------------------------------------------------------------------------*/
/**
 * Get captured value.
 * @param capture Pointer to a Capture object.
 * @return Value of the counter measured in timer ticks.
 */
static inline uint32_t captureValue(const void *capture)
{
  return ((const struct CaptureClass *)CLASS(capture))->value(capture);
}
/*----------------------------------------------------------------------------*/
#endif /* CAPTURE_H_ */
{'fraction_non_alphanumeric': 0.3579247977153736, 'fraction_numerical': 0.00475963826749167, 'mean_word_length': 1.5234093637454982, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 10, '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': '869924', 'n_tokens_mistral': 490, 'n_tokens_neox': 475, 'n_words': 163}