<commit_before>#ifndef USI_CORE_DELEGATE_H_
#define USI_CORE_DELEGATE_H_

#include <systemc.h>
#include <vector>
#include "usi.h"

class USIDelegate;

class USIBaseDelegate {
  public:
    const char *name() { return (m_object) ? m_object->name(): ""; }
    const char *basename() { return (m_object) ? m_object->basename(): ""; }
    const char *kind() { return (m_object) ? m_object->kind(): ""; }
    sc_core::sc_object *parent() {
      if(m_object) {
        return m_object->get_parent();
      } else {
        return NULL;
      }
    }

    std::vector<sc_core::sc_object *> children() {
      if(m_object) {
        return m_object->get_child_objects();
      } else {
        return std::vector<sc_core::sc_object *>();
      }
    }

#ifndef SWIG
    USIBaseDelegate(): m_object(NULL) {}<commit_msg>gs_params do not follow systemc names, do teach the delegates to use gs_param values when applicable<commit_after>#ifndef USI_CORE_DELEGATE_H_
#define USI_CORE_DELEGATE_H_

#include <systemc.h>
#include <vector>
#include "usi.h"
#include "core/common/gs_config.h"

class USIDelegate;

class USIBaseDelegate {
  public:
    const char *name() {
      gs::cnf::gs_param_base *param = dynamic_cast<gs::cnf::gs_param_base *>(m_object);
      if(param) {
        return param->getName().c_str();
      } else if(m_object) {
        return m_object->name();
      } else {
        return "";
      }

    }
    const char *basename() {
      gs::cnf::gs_param_base *param = dynamic_cast<gs::cnf::gs_param_base *>(m_object);
      if(param) {
        size_t offset = 0;
        sc_core::sc_object *parent = m_object->get_parent();
        gs::cnf::gs_param_base *parent_param = dynamic_cast<gs::cnf::gs_param_base *>(parent);
        if(parent_param) {
          offset = parent_param->getName().length();
        } else if(parent) {
          offset = sizeof(parent->name());
        }
        if(offset) {
          offset++;
        }
        return param->getName().substr(offset).c_str();
      } else if(m_object) {
        return m_object->basename();
      } else {
        return "";
      }
    }
    const char *kind() {
      gs::cnf::gs_param_base *param = dynamic_cast<gs::cnf::gs_param_base *>(m_object);
      if(param) {
        return param->getTypeString().c_str();
      } else if(m_object) {
        return m_object->kind();
      } else {
        return "";
      }
    }
    sc_core::sc_object *parent() {
      if(m_object) {
        return m_object->get_parent();
      } else {
        return NULL;
      }
    }

    std::vector<sc_core::sc_object *> children() {
      if(m_object) {
        return m_object->get_child_objects();
      } else {
        return std::vector<sc_core::sc_object *>();
      }
    }

#ifndef SWIG
    USIBaseDelegate(): m_object(NULL) {}
{'fraction_non_alphanumeric': 0.1480157311405077, 'fraction_numerical': 0.0003575259206292456, 'mean_word_length': 2.6479791395045633, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 31, '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': '6469653', 'n_tokens_mistral': 969, 'n_tokens_neox': 958, 'n_words': 172}