<commit_before>/// \file ROOT/Canvas.h
/// \ingroup Gpad ROOT7
/// \author <NAME> <<EMAIL>>
/// \date 2015-07-08
/// \warning This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback is welcome!

/*************************************************************************
 * Copyright (C) 1995-2015, <NAME> and <NAME>.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/

#ifndef ROOT7_TCanvas
#define ROOT7_TCanvas

#include <experimental/string_view>
#include <memory>
#include <string>
#include <vector>

#include "ROOT/TDrawable.h"

namespace ROOT {
namespace Experimental {

namespace Internal {
class TCanvasSharedPtrMaker;
class TV5CanvasAdaptor;
}

/** \class ROOT::Experimental::TCanvas
  Graphic container for `TDrawable`-s.
  Access is through TCanvasPtr.
  */

class TCanvas {
public:
  using Primitives_t = std::vector<std::unique_ptr<Internal::TDrawable>>;

private:
  /// Content of the pad.
  Primitives_t fPrimitives;

  /// Title of the canvas.
  std::string fTitle;

  /// Adaptor for painting an old canvas.
  std::unique_ptr<Internal::TV5CanvasAdaptor> fAdaptor;

  /// Disable copy construction for now.
  TCanvas(const TCanvas&) = delete;

  /// Disable assignment for now.
  TCanvas& operator=(const TCanvas&) = delete;

public:
  static std::shared_ptr<TCanvas> Create(const std::string& title);

  /// Create a temporary Canvas; for long-lived ones please use Create().
  TCanvas();

  /// Default destructor.
  ///
  /// Outline the implementation in sources.
  ~TCanvas();

  /// Add a something to be painted. The pad claims shared ownership.
  template<class T>
  void Draw(std::shared_ptr <T> what) {
    // Requires GetDrawable(what, options) to be known!
    fPrimitives.emplace_back(GetDrawable(what));
  }

  /// Add a something to be painted, with options. The pad claims shared ownership.
  template<class T, class OPTIONS>
  void Draw(std::shared_ptr <T> what, const OPTIONS &options) {
    // Requires GetDrawable(what, options) to be known!
    fPrimitives.emplace_back(GetDrawable(what, options));
  }

  /// Remove an object from the list of primitives.
  //TODO: void Wipe();

  /// Paint the canvas elements ("primitives").
  void Paint();

  /// Get the canvas's title.
  const std::string& GetTitle() const { return fTitle; }

  /// Set the canvas's title.
  void SetTitle(const std::string& title) { fTitle = title; }

  /// Get the elements contained in the canvas.
  const Primitives_t& GetPrimitives();


  static const std::vector<std::shared_ptr<TCanvas>> &GetCanvases();
};
<commit_msg>Implement GetPrimitives()...<commit_after>/// \file ROOT/Canvas.h
/// \ingroup Gpad ROOT7
/// \author <NAME> <<EMAIL>>
/// \date 2015-07-08
/// \warning This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback is welcome!

/*************************************************************************
 * Copyright (C) 1995-2015, <NAME> and <NAME>.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/

#ifndef ROOT7_TCanvas
#define ROOT7_TCanvas

#include <experimental/string_view>
#include <memory>
#include <string>
#include <vector>

#include "ROOT/TDrawable.h"

namespace ROOT {
namespace Experimental {

namespace Internal {
class TCanvasSharedPtrMaker;
class TV5CanvasAdaptor;
}

/** \class ROOT::Experimental::TCanvas
  Graphic container for `TDrawable`-s.
  Access is through TCanvasPtr.
  */

class TCanvas {
public:
  using Primitives_t = std::vector<std::unique_ptr<Internal::TDrawable>>;

private:
  /// Content of the pad.
  Primitives_t fPrimitives;

  /// Title of the canvas.
  std::string fTitle;

  /// Adaptor for painting an old canvas.
  std::unique_ptr<Internal::TV5CanvasAdaptor> fAdaptor;

  /// Disable copy construction for now.
  TCanvas(const TCanvas&) = delete;

  /// Disable assignment for now.
  TCanvas& operator=(const TCanvas&) = delete;

public:
  static std::shared_ptr<TCanvas> Create(const std::string& title);

  /// Create a temporary Canvas; for long-lived ones please use Create().
  TCanvas();

  /// Default destructor.
  ///
  /// Outline the implementation in sources.
  ~TCanvas();

  /// Add a something to be painted. The pad claims shared ownership.
  template<class T>
  void Draw(std::shared_ptr <T> what) {
    // Requires GetDrawable(what, options) to be known!
    fPrimitives.emplace_back(GetDrawable(what));
  }

  /// Add a something to be painted, with options. The pad claims shared ownership.
  template<class T, class OPTIONS>
  void Draw(std::shared_ptr <T> what, const OPTIONS &options) {
    // Requires GetDrawable(what, options) to be known!
    fPrimitives.emplace_back(GetDrawable(what, options));
  }

  /// Remove an object from the list of primitives.
  //TODO: void Wipe();

  /// Paint the canvas elements ("primitives").
  void Paint();

  /// Get the canvas's title.
  const std::string& GetTitle() const { return fTitle; }

  /// Set the canvas's title.
  void SetTitle(const std::string& title) { fTitle = title; }

  /// Get the elements contained in the canvas.
  const Primitives_t& GetPrimitives() { return fPrimitives; }


  static const std::vector<std::shared_ptr<TCanvas>> &GetCanvases();
};

{'fraction_non_alphanumeric': 0.16299185888738127, 'fraction_numerical': 0.007462686567164179, 'mean_word_length': 2.997966101694915, 'pattern_counts': {'":': 0, '<': 41, '<?xml version=': 0, '>': 41, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4916480', 'n_tokens_mistral': 1765, 'n_tokens_neox': 1655, 'n_words': 531}