<commit_before>// @(#)root/eve7:$Id$
// Authors: <NAME> & <NAME>: 2018

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

#ifndef ROOT7_REveTableInfo
#define ROOT7_REveTableInfo

#include <ROOT/REveElement.hxx>
#include <ROOT/REveDataCollection.hxx>
#include <ROOT/REveDataTable.hxx>

namespace ROOT {
namespace Experimental {

///////////////////////////////////////////////////////////////////////////////
/// REveTableEntry
///////////////////////////////////////////////////////////////////////////////

class REveTableEntry {
public:
   std::string    fName;
   int            fPrecision;
   std::string    fExpression;
   REveDataColumn::FieldType_e fType;

   REveTableEntry() : fName("unknown"), fPrecision(2), fType(REveDataColumn::FT_Double) {}

   REveTableEntry(const std::string &name, int precision, const std::string &expression)
      : fName(name), fPrecision(precision), fExpression(expression), fType(REveDataColumn::FT_Double)
   {
   }

   void Print() const
   {
      printf("TableEntry\n");
      printf("name: %s expression: %s\n", fName.c_str(), fExpression.c_str());
   }
};

///////////////////////////////////////////////////////////////////////////////
/// REveTableHandle
///////////////////////////////////////////////////////////////////////////////

class REveTableHandle
{
   friend class REveTableViewInfo;

public:
   typedef std::vector<REveTableEntry> Entries_t;
   typedef std::map<std::string, Entries_t> Specs_t;

   // REveTableHandle() {}

   REveTableHandle&
   column(const std::string &name, int precision, const std::string &expression)
   {
      fSpecs[fClassName].emplace_back(name, precision, expression);
      return *this;
   }

   REveTableHandle &column(const std::string &label, int precision)
   {
      return column(label, precision, label);
   }

   REveTableHandle(std::string className, Specs_t &specs)
      :fClassName(className), fSpecs(specs)
   {
   }

protected:
   std::string  fClassName;
   Specs_t&  fSpecs;
};

///////////////////////////////////////////////////////////////////////////////
/// REveTableViewInfo
///////////////////////////////////////////////////////////////////////////////

class REveTableViewInfo : public REveElement
{
public:
   REveTableViewInfo(const std::string &name = "TableViewManager", const std::string &title = "");

   typedef std::function<void ()> Delegate_t;

   void SetDisplayedCollection(ElementId_t);
   ElementId_t GetDisplayedCollection() const  { return fDisplayedCollection; }

   void AddNewColumnToCurrentCollection(const char* expr, const char* title, int prec = 2);

   void AddDelegate(Delegate_t d) { fDelegates.push_back(d); }

   Int_t WriteCoreJson(nlohmann::json &j, Int_t rnr_offset) override;

   // read
   REveTableHandle::Entries_t &RefTableEntries(std::string cname);

   // filling
   REveTableHandle table(std::string className)
   {
      REveTableHandle handle(className, fSpecs);
      return handle;
   }

   bool GetConfigChanged() const { return fConfigChanged; }


private:
   int fDisplayedCollection{0};
   std::vector<Delegate_t> fDelegates;
   REveTableHandle::Specs_t  fSpecs;
   bool                      fConfigChanged{false};
};


}
}

#endif<commit_msg>Add getter for table specfication.<commit_after>// @(#)root/eve7:$Id$
// Authors: <NAME> & <NAME>: 2018

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

#ifndef ROOT7_REveTableInfo
#define ROOT7_REveTableInfo

#include <ROOT/REveElement.hxx>
#include <ROOT/REveDataCollection.hxx>
#include <ROOT/REveDataTable.hxx>

namespace ROOT {
namespace Experimental {

///////////////////////////////////////////////////////////////////////////////
/// REveTableEntry
///////////////////////////////////////////////////////////////////////////////

class REveTableEntry {
public:
   std::string    fName;
   int            fPrecision;
   std::string    fExpression;
   REveDataColumn::FieldType_e fType;

   REveTableEntry() : fName("unknown"), fPrecision(2), fType(REveDataColumn::FT_Double) {}

   REveTableEntry(const std::string &name, int precision, const std::string &expression)
      : fName(name), fPrecision(precision), fExpression(expression), fType(REveDataColumn::FT_Double)
   {
   }

   void Print() const
   {
      printf("TableEntry\n");
      printf("name: %s expression: %s\n", fName.c_str(), fExpression.c_str());
   }
};

///////////////////////////////////////////////////////////////////////////////
/// REveTableHandle
///////////////////////////////////////////////////////////////////////////////

class REveTableHandle
{
   friend class REveTableViewInfo;

public:
   typedef std::vector<REveTableEntry> Entries_t;
   typedef std::map<std::string, Entries_t> Specs_t;

   // REveTableHandle() {}

   REveTableHandle&
   column(const std::string &name, int precision, const std::string &expression)
   {
      fSpecs[fClassName].emplace_back(name, precision, expression);
      return *this;
   }

   REveTableHandle &column(const std::string &label, int precision)
   {
      return column(label, precision, label);
   }

   REveTableHandle(std::string className, Specs_t &specs)
      :fClassName(className), fSpecs(specs)
   {
   }

protected:
   std::string  fClassName;
   Specs_t&  fSpecs;
};

///////////////////////////////////////////////////////////////////////////////
/// REveTableViewInfo
///////////////////////////////////////////////////////////////////////////////

class REveTableViewInfo : public REveElement
{
public:
   REveTableViewInfo(const std::string &name = "TableViewManager", const std::string &title = "");

   typedef std::function<void ()> Delegate_t;

   void SetDisplayedCollection(ElementId_t);
   ElementId_t GetDisplayedCollection() const  { return fDisplayedCollection; }

   void AddNewColumnToCurrentCollection(const char* expr, const char* title, int prec = 2);

   void AddDelegate(Delegate_t d) { fDelegates.push_back(d); }

   Int_t WriteCoreJson(nlohmann::json &j, Int_t rnr_offset) override;

   // read
   REveTableHandle::Entries_t &RefTableEntries(std::string cname);

   // filling
   REveTableHandle table(std::string className)
   {
      REveTableHandle handle(className, fSpecs);
      return handle;
   }

   bool GetConfigChanged() const { return fConfigChanged; }

   REveTableHandle::Specs_t& RefSpecs() { return fSpecs; }
private:
   int fDisplayedCollection{0};
   std::vector<Delegate_t> fDelegates;
   REveTableHandle::Specs_t  fSpecs;
   bool                      fConfigChanged{false};
};


}
}

#endif
{'fraction_non_alphanumeric': 0.26263306831963346, 'fraction_numerical': 0.004851098234739253, 'mean_word_length': 2.0293877551020407, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 25, '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': '6704401', 'n_tokens_mistral': 2054, 'n_tokens_neox': 1957, 'n_words': 409}