<commit_before>// --------------------------------------------------------
// Code generated by Papyrus C++
// --------------------------------------------------------

#define Annotator_AnnotatorLib_Session_BODY

/************************************************************
 Session class body
 ************************************************************/

// include associated header file
#include "AnnotatorLib/Session.h"
#include <algorithm>

namespace AnnotatorLib {

Session::Session() {}

Session::~Session() {
  clearAll();
}

void Session::clearAll() {
  // clear all
  this->objects.clear();
  this->frames.clear();
  this->annotations.clear();
  this->classes.clear();
  this->attributes.clear();
  this->commands.clear();
}

template<typename K, typename T>
std::shared_ptr<T> find_smart_pointer( std::unordered_map< K, std::shared_ptr<T>> map, K key ) {
    auto got = map.find(key);
    if(got != map.end()) {
      return got->second;
    }
    return shared_ptr<T>(nullptr);
}

template<typename K, typename T>
T* find_raw_pointer( std::unordered_map< K, std::shared_ptr<T>> map, K key ) {
    return find_smart_pointer<K,T>(map, key).get();
}

bool Session::addAttribute(const shared_ptr<Attribute> attribute) {
  if (attribute) return false;
  return attributes.insert(std::make_pair(attribute->getId(), std::move(attribute))).second;
}

shared_ptr<Attribute> Session::removeAttribute(Attribute *attribute) {
  std::shared_ptr<Attribute> got = find_smart_pointer<unsigned long, Attribute>(attributes, attribute->getId());
  if(got) {
    attributes.erase(attribute->getId());
  }
  return got;
}

shared_ptr<Attribute> Session::getAttribute(unsigned long id) const {
  return find_smart_pointer<unsigned long, Attribute>(attributes, id);<commit_msg>reset command index when clearing session<commit_after>// --------------------------------------------------------
// Code generated by Papyrus C++
// --------------------------------------------------------

#define Annotator_AnnotatorLib_Session_BODY

/************************************************************
 Session class body
 ************************************************************/

// include associated header file
#include "AnnotatorLib/Session.h"
#include <algorithm>

namespace AnnotatorLib {

Session::Session() {}

Session::~Session() {
  clearAll();
}

void Session::clearAll() {
  // clear all
  this->objects.clear();
  this->frames.clear();
  this->annotations.clear();
  this->classes.clear();
  this->attributes.clear();
  this->commands.clear();
  commandIndex = 0;
}

template<typename K, typename T>
std::shared_ptr<T> find_smart_pointer( std::unordered_map< K, std::shared_ptr<T>> map, K key ) {
    auto got = map.find(key);
    if(got != map.end()) {
      return got->second;
    }
    return shared_ptr<T>(nullptr);
}

template<typename K, typename T>
T* find_raw_pointer( std::unordered_map< K, std::shared_ptr<T>> map, K key ) {
    return find_smart_pointer<K,T>(map, key).get();
}

bool Session::addAttribute(const shared_ptr<Attribute> attribute) {
  if (attribute) return false;
  return attributes.insert(std::make_pair(attribute->getId(), std::move(attribute))).second;
}

shared_ptr<Attribute> Session::removeAttribute(Attribute *attribute) {
  std::shared_ptr<Attribute> got = find_smart_pointer<unsigned long, Attribute>(attributes, attribute->getId());
  if(got) {
    attributes.erase(attribute->getId());
  }
  return got;
}

shared_ptr<Attribute> Session::getAttribute(unsigned long id) const {
  return find_smart_pointer<unsigned long, Attribute>(attributes, id);
{'fraction_non_alphanumeric': 0.26198439241917504, 'fraction_numerical': 0.0002787068004459309, 'mean_word_length': 3.950344827586207, 'pattern_counts': {'":': 0, '<': 35, '<?xml version=': 0, '>': 55, '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': '2542308', 'n_tokens_mistral': 1016, 'n_tokens_neox': 1014, 'n_words': 214}