<commit_before>/**
 * Provides a class that manages properties for some class (e.g. IEntity). By
 * providing a PropertyManager class, other classes can easily add a flexible
 * property management system if desired.
 *
 * @file include/GQE/Entity/classes/PropertyManager.hpp
 * @author <NAME>
 * @date 20120615 - Initial Release
 * @date 20120622 - Fix warning and error comments
 * @date 20120630 - Fix documentation of various methods
 */
#ifndef PROPERTY_MANAGER_HPP_INCLUDED
#define PROPERTY_MANAGER_HPP_INCLUDED

#include <map>
#include <typeinfo>
#include <GQE/Core/loggers/Log_macros.hpp>
#include <GQE/Core/interfaces/IProperty.hpp>
#include <GQE/Core/interfaces/TProperty.hpp>
#include <GQE/Core/Core_types.hpp>

namespace GQE
{
  /// Provides the PropertyManager class for managing IProperty classes
  class GQE_API PropertyManager
  {
    public:
      /**
       * PropertyManager default constructor
       */
      PropertyManager();

      /**
       * PropertyManager deconstructor
       */
      virtual ~PropertyManager();

      /**
       * HasID returns true if thePropertyID specified exists in this
       * PropertyManager.
       * @param[in] thePropertyID to lookup in this PropertyManager
       * @return true if thePropertyID exists, false otherwise
       */
      bool HasID(const typePropertyID thePropertyID) const;

      /**
       * Get returns the property as type with the ID of thePropertyID.
       * @param[in] thePropertyID is the ID of the property to return.
       * @return the value stored in the found propery in the form of TYPE. If no
       * Property was found it returns the default value the type constructor.
       */
      template<class TYPE>
      TYPE Get(const typePropertyID thePropertyID)
      {
        if(mList.find(thePropertyID) != mList.end())
        {
          if(mList.at(thePropertyID)->GetType()->Name() == typeid(TYPE).name())
            return static_cast<TProperty<TYPE>*>(mList[thePropertyID])->GetValue();
        }
        else
        {
          WLOG() << "PropertyManager:Get() returning blank property("
            << thePropertyID << ") type" << std::endl;
        }
        TYPE anReturn=TYPE();
        return anReturn;
      }
       /**
       * GetProperty returns the property as TProperty<TYPE> with the ID of thePropertyID.
       * @param[in] thePropertyID is the ID of the property to return.
       * @return A reference to a TProperty<TYPE> object.
       */
      template<class TYPE>
      TProperty<TYPE>& GetProperty(const typePropertyID thePropertyID)
      {
        if(mList.find(thePropertyID) != mList.end())
        {
          if(mList.at(thePropertyID)->GetType()->Name() == typeid(TYPE).name())
            return static_cast<TProperty<TYPE>&>(mList[thePropertyID]);
        }
        else
        {
          WLOG() << "PropertyManager:Get() returning blank property("
            << thePropertyID << ") type" << std::endl;
        }
        TYPE anReturn=TYPE();
        return anReturn;
      }
      /**
       * Set sets the property with the ID of thePropertyID to theValue.
       * @param[in] thePropertyID is the ID of the property to set.
       * @param[in] theValue is the value to set.
       */
      template<class TYPE>
      void Set(const typePropertyID thePropertyID, TYPE theValue)
      {
        if(mList.find(thePropertyID) != mList.end())
        {
          if(mList.at(thePropertyID)->GetType()->Name() == typeid(TYPE).name())
          {
            static_cast<TProperty<TYPE>*>(mList[thePropertyID])->SetValue(theValue);
          }
        }
        else
        {
          ELOG() << "PropertyManager:Set() unable to find property("
            << thePropertyID << ")" << std::endl;
        }
      }

      /**
       * Add creates a Property and addes it to this PropertyManager.
       * @param[in] thePropertyID is the ID of the property to create.<commit_msg>Added log warnings for mismatching property types.<commit_after>/**
 * Provides a class that manages properties for some class (e.g. IEntity). By
 * providing a PropertyManager class, other classes can easily add a flexible
 * property management system if desired.
 *
 * @file include/GQE/Entity/classes/PropertyManager.hpp
 * @author <NAME>
 * @date 20120615 - Initial Release
 * @date 20120622 - Fix warning and error comments
 * @date 20120630 - Fix documentation of various methods
 */
#ifndef PROPERTY_MANAGER_HPP_INCLUDED
#define PROPERTY_MANAGER_HPP_INCLUDED

#include <map>
#include <typeinfo>
#include <GQE/Core/loggers/Log_macros.hpp>
#include <GQE/Core/interfaces/IProperty.hpp>
#include <GQE/Core/interfaces/TProperty.hpp>
#include <GQE/Core/Core_types.hpp>

namespace GQE
{
  /// Provides the PropertyManager class for managing IProperty classes
  class GQE_API PropertyManager
  {
    public:
      /**
       * PropertyManager default constructor
       */
      PropertyManager();

      /**
       * PropertyManager deconstructor
       */
      virtual ~PropertyManager();

      /**
       * HasID returns true if thePropertyID specified exists in this
       * PropertyManager.
       * @param[in] thePropertyID to lookup in this PropertyManager
       * @return true if thePropertyID exists, false otherwise
       */
      bool HasID(const typePropertyID thePropertyID) const;

      /**
       * Get returns the property as type with the ID of thePropertyID.
       * @param[in] thePropertyID is the ID of the property to return.
       * @return the value stored in the found propery in the form of TYPE. If no
       * Property was found it returns the default value the type constructor.
       */
      template<class TYPE>
      TYPE Get(const typePropertyID thePropertyID)
      {
        if(mList.find(thePropertyID) != mList.end())
        {
          if(mList.at(thePropertyID)->GetType()->Name() == typeid(TYPE).name())
            return static_cast<TProperty<TYPE>*>(mList[thePropertyID])->GetValue();
        }
        else
        {
          WLOG() << "PropertyManager:Get() returning blank property("
            << thePropertyID << ") type" << std::endl;
        }
        TYPE anReturn=TYPE();
        return anReturn;
      }
       /**
       * GetProperty returns the property as TProperty<TYPE> with the ID of thePropertyID.
       * @param[in] thePropertyID is the ID of the property to return.
       * @return A reference to a TProperty<TYPE> object.
       */
      template<class TYPE>
      TProperty<TYPE>& GetProperty(const typePropertyID thePropertyID)
      {
        if(mList.find(thePropertyID) != mList.end())
        {
          if(mList.at(thePropertyID)->GetType()->Name() == typeid(TYPE).name())
            return static_cast<TProperty<TYPE>&>(mList[thePropertyID]);
          else
            WLOG() << "PropertyManager:Get() Incorrect type,"
            << typeid(TYPE).name() << ", expected: "<< mList.at(thePropertyID)->GetType()->Name() << std::endl;
        }
        else
        {
          WLOG() << "PropertyManager:Get() returning blank property("
            << thePropertyID << ") type" << std::endl;
        }
        TYPE anReturn=TYPE();
        return anReturn;
      }
      /**
       * Set sets the property with the ID of thePropertyID to theValue.
       * @param[in] thePropertyID is the ID of the property to set.
       * @param[in] theValue is the value to set.
       */
      template<class TYPE>
      void Set(const typePropertyID thePropertyID, TYPE theValue)
      {
        if(mList.find(thePropertyID) != mList.end())
        {
          if(mList.at(thePropertyID)->GetType()->Name() == typeid(TYPE).name())
          {
            static_cast<TProperty<TYPE>*>(mList[thePropertyID])->SetValue(theValue);
          }
          else
          {
            WLOG() << "PropertyManager:Set() Incorrect type,"
            << typeid(TYPE).name() << ", expected: "<< mList.at(thePropertyID)->GetType()->Name() << std::endl;\
          }
        }
        else
        {
          ELOG() << "PropertyManager:Set() unable to find property("
            << thePropertyID << ")" << std::endl;
        }
      }

      /**
       * Add creates a Property and addes it to this PropertyManager.
       * @param[in] thePropertyID is the ID of the property to create.
{'fraction_non_alphanumeric': 0.11210653753026634, 'fraction_numerical': 0.005811138014527845, 'mean_word_length': 2.437786100707449, 'pattern_counts': {'":': 0, '<': 109, '<?xml version=': 0, '>': 61, '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': '2640712', 'n_tokens_mistral': 2354, 'n_tokens_neox': 2304, 'n_words': 649}