<commit_before>/*----------------------------------------------------------------------------*/
/* Copyright (c) FIRST 2016. All Rights Reserved.                             */
/* Open Source Software - may be modified and shared by FRC teams. The code   */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project.                                                               */
/*----------------------------------------------------------------------------*/

#ifndef CS_FRAME_H_
#define CS_FRAME_H_

#include <atomic>
#include <memory>

#include "llvm/StringRef.h"

#include "cscore_cpp.h"

namespace cs {

class SourceImpl;

class Frame {
  friend class SourceImpl;

 public:
  typedef uint64_t Time;

 private:
  struct Data {
    explicit Data(std::size_t capacity_)
        : data(new char[capacity_]), size(0), capacity(capacity_) {}
    ~Data() { delete[] data; }

    std::atomic_int refcount{0};
    Time time;
    char* data;
    std::size_t size;
    std::size_t capacity;
    VideoMode::PixelFormat pixelFormat;
    int width;
    int height;
  };

 public:
  Frame() noexcept : m_source{nullptr}, m_data{nullptr} {}

  Frame(SourceImpl& source, std::unique_ptr<Data> data) noexcept
      : m_source{&source},
        m_data{data.release()} {
    if (m_data) ++(m_data->refcount);
  }

  Frame(const Frame& frame) noexcept : m_source{frame.m_source},
                                       m_data{frame.m_data} {
    if (m_data) ++(m_data->refcount);
  }

  Frame(Frame&& other) noexcept : Frame() { swap(*this, other); }<commit_msg>Frame: Make Data struct public.<commit_after>/*----------------------------------------------------------------------------*/
/* Copyright (c) FIRST 2016. All Rights Reserved.                             */
/* Open Source Software - may be modified and shared by FRC teams. The code   */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project.                                                               */
/*----------------------------------------------------------------------------*/

#ifndef CS_FRAME_H_
#define CS_FRAME_H_

#include <atomic>
#include <memory>

#include "llvm/StringRef.h"

#include "cscore_cpp.h"

namespace cs {

class SourceImpl;

class Frame {
  friend class SourceImpl;

 public:
  typedef uint64_t Time;

  struct Data {
    explicit Data(std::size_t capacity_)
        : data(new char[capacity_]), size(0), capacity(capacity_) {}
    ~Data() { delete[] data; }

    std::atomic_int refcount{0};
    Time time;
    char* data;
    std::size_t size;
    std::size_t capacity;
    VideoMode::PixelFormat pixelFormat;
    int width;
    int height;
  };

 public:
  Frame() noexcept : m_source{nullptr}, m_data{nullptr} {}

  Frame(SourceImpl& source, std::unique_ptr<Data> data) noexcept
      : m_source{&source},
        m_data{data.release()} {
    if (m_data) ++(m_data->refcount);
  }

  Frame(const Frame& frame) noexcept : m_source{frame.m_source},
                                       m_data{frame.m_data} {
    if (m_data) ++(m_data->refcount);
  }

  Frame(Frame&& other) noexcept : Frame() { swap(*this, other); }
{'fraction_non_alphanumeric': 0.20961659333752358, 'fraction_numerical': 0.00502828409805154, 'mean_word_length': 1.8118374558303887, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1294076', 'n_tokens_mistral': 921, 'n_tokens_neox': 894, 'n_words': 245}