<commit_before>#pragma once
/*
** Author(s):
**  - <NAME> <<EMAIL>>
**
** Copyright (C) 2010 Aldebaran Robotics
*/
#ifndef COMMON_MUTEXEDNAMELOOKUP_HPP_
#define COMMON_MUTEXEDNAMELOOKUP_HPP_

#include <map>
#include <boost/thread/thread.hpp>
#include <boost/thread/mutex.hpp>

namespace AL {
  namespace Common {

    template<typename T>
    class MutexedNameLookup {
    private:
      std::map<std::string, T> fMap;
      T fInvalidValue;
      boost::mutex fMutex;
    public:
      MutexedNameLookup() {};

      void replace(std::map<std::string, T>& other) {
        boost::mutex::scoped_lock lock(fMutex);
        fMap = other;
      }

      const std::map<std::string, T>& getMap() {
        boost::mutex::scoped_lock lock(fMutex);
        return fMap;
      }

      const T& get(std::string key) {
        boost::mutex::scoped_lock lock(fMutex);
        std::map<std::string, T>::const_iterator it = fMap.find(key);
        if (it != fMap.end()) {
          return it->second;
        }
        return fInvalidValue;
      }
      
      void insert(const std::string key, const T& val) {
        if (get(key).nodeName == "") {
          remove(key);
        }
        
        {
          boost::mutex::scoped_lock lock(fMutex);
          fMap.insert(make_pair(key, val));
        }
      }

      void remove(const std::string key) {
        boost::mutex::scoped_lock lock(fMutex);
        fMap.erase(key);
      }


    };
  }
}

#endif  // COMMON_MUTEXEDNAMELOOKUP_HPP_

<commit_msg>fix gcc compilation<commit_after>#pragma once
/*
** Author(s):
**  - <NAME> <<EMAIL>>
**
** Copyright (C) 2010 Aldebaran Robotics
*/
#ifndef COMMON_MUTEXEDNAMELOOKUP_HPP_
#define COMMON_MUTEXEDNAMELOOKUP_HPP_

#include <map>
#include <boost/thread/thread.hpp>
#include <boost/thread/mutex.hpp>

namespace AL {
  namespace Common {

    template<typename T>
    class MutexedNameLookup {
    private:
      std::map<std::string, T> fMap;
      T fInvalidValue;
      boost::mutex fMutex;
    public:
      MutexedNameLookup() {};

      void replace(std::map<std::string, T>& other) {
        boost::mutex::scoped_lock lock(fMutex);
        fMap = other;
      }

      const std::map<std::string, T>& getMap() {
        boost::mutex::scoped_lock lock(fMutex);
        return fMap;
      }

      const T& get(std::string key) {
        boost::mutex::scoped_lock lock(fMutex);
        typename std::map<std::string, T>::const_iterator it = fMap.find(key);
        if (it != fMap.end()) {
          return it->second;
        }
        return fInvalidValue;
      }

      void insert(const std::string key, const T& val) {
        if (get(key).nodeName == "") {
          remove(key);
        }

        {
          boost::mutex::scoped_lock lock(fMutex);
          fMap.insert(make_pair(key, val));
        }
      }

      void remove(const std::string key) {
        boost::mutex::scoped_lock lock(fMutex);
        fMap.erase(key);
      }


    };
  }
}

#endif  // COMMON_MUTEXEDNAMELOOKUP_HPP_


{'fraction_non_alphanumeric': 0.13588516746411483, 'fraction_numerical': 0.002551834130781499, 'mean_word_length': 2.0927021696252464, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 27, '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': '4795347', 'n_tokens_mistral': 1084, 'n_tokens_neox': 1044, 'n_words': 191}