<commit_before>/// \file ROOT/TDrawingOptsBase.hxx
/// \ingroup Gpad ROOT7
/// \author <NAME> <<EMAIL>>
/// \date 2017-09-26
/// \warning This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback
/// is welcome!

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

#ifndef ROOT7_TDrawingOptsBase
#define ROOT7_TDrawingOptsBase

#include <RStringView.h>
#include <map>
#include <string>

namespace ROOT {
namespace Experimental {
namespace Internal {
/// Implementation.
std::map<std::string, std::string> ReadDrawingOptsDefaultConfig(std::string_view section);
} // namespace Internal

namespace Detail {

/** \class ROOT::Experimental::Detail::TDrawingOptsBase
  Base class for drawing options. Implements access to the default and the default's initialization
  from a config file.

  Derived classes must implement `InitializeDefaultFromFile()`.
  */
template <class DERIVED>
class TDrawingOptsBase {
protected:
   const DERIVED &ToDerived() const { return static_cast<DERIVED &>(*this); }
   DERIVED &ToDerived() { return static_cast<DERIVED &>(*this); }

   /// Read the configuration for section from the config file. Used by derived classes to
   /// initialize their default, in `InitializeDefaultFromFile()`.
   static std::map<std::string, std::string> ReadConfig(std::string_view section)
   {
      return ReadDrawingOptsDefaultConfig(section);
   }

   /// Default implementation: no configuration variables in config file, simply default-initialize
   /// the drawing options.
   static DERIVED InitializeDefaultFromFile() { return DERIVED(); }

public:
   /// Retrieve the default drawing options for `DERIVED`. Can be used to query and adjust the
   /// default options.
   static DERIVED &Default()
   {
      static DERIVED defaultOpts = DERIVED::InitializeDefaultFromFile();
      return defaultOpts;
   }
};

} // namespace Detail
} // namespace Experimental
} // namespace ROOT

#endif
<commit_msg>Move TDrawingOptsBase out of Detail: Default() is common.<commit_after>/// \file ROOT/TDrawingOptsBase.hxx
/// \ingroup Gpad ROOT7
/// \author <NAME> <<EMAIL>>
/// \date 2017-09-26
/// \warning This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback
/// is welcome!

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

#ifndef ROOT7_TDrawingOptsBase
#define ROOT7_TDrawingOptsBase

#include <RStringView.h>
#include <map>
#include <string>

namespace ROOT {
namespace Experimental {
namespace Internal {
/// Implementation.
std::map<std::string, std::string> ReadDrawingOptsDefaultConfig(std::string_view section);
} // namespace Internal

/** \class ROOT::Experimental::TDrawingOptsBase
  Base class for drawing options. Implements access to the default and the default's initialization
  from a config file.

  Derived classes must implement `InitializeDefaultFromFile()`.
  */
template <class DERIVED>
class TDrawingOptsBase {
protected:
   const DERIVED &ToDerived() const { return static_cast<DERIVED &>(*this); }
   DERIVED &ToDerived() { return static_cast<DERIVED &>(*this); }

   /// Read the configuration for section from the config file. Used by derived classes to
   /// initialize their default, in `InitializeDefaultFromFile()`.
   static std::map<std::string, std::string> ReadConfig(std::string_view section)
   {
      return Internal::ReadDrawingOptsDefaultConfig(section);
   }

   /// Default implementation: no configuration variables in config file, simply default-initialize
   /// the drawing options.
   static DERIVED InitializeDefaultFromFile() { return DERIVED(); }

public:
   /// Retrieve the default drawing options for `DERIVED`. Can be used to query and adjust the
   /// default options.
   static DERIVED &Default()
   {
      static DERIVED defaultOpts = DERIVED::InitializeDefaultFromFile();
      return defaultOpts;
   }
};

} // namespace Experimental
} // namespace ROOT

#endif

{'fraction_non_alphanumeric': 0.15735414954806903, 'fraction_numerical': 0.008216926869350863, 'mean_word_length': 3.1227773073666385, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 29, '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': '5821261', 'n_tokens_mistral': 1288, 'n_tokens_neox': 1244, 'n_words': 403}