<commit_before>#ifndef MIMOSA_REF_COUNTABLE_HH
# define MIMOSA_REF_COUNTABLE_HH

# include "ref-counted-ptr.hh"

namespace mimosa
{
  class RefCountableBase
  {
  public:
    inline RefCountableBase()
      : ref_count_(0)
    {
    }

    inline RefCountableBase(const RefCountableBase & /*other*/)
      : ref_count_(0)
    {
    }

    virtual ~RefCountableBase() {}

    inline RefCountableBase & operator=(const RefCountableBase & /*other*/)
    {
      return *this;
    }

    inline int addRef() const
    {
      return __sync_add_and_fetch(&ref_count_, 1);
    }

    inline int releaseRef() const
    {
      return __sync_add_and_fetch(&ref_count_, -1);
    }

    mutable int ref_count_;
  };

  inline void addRef(const RefCountableBase * obj)
  {
    obj->addRef();
  }

  inline void releaseRef(const RefCountableBase * obj)
  {
    if (obj->releaseRef() == 0)
      delete obj;
  }

  template <typename T>
  class RefCountable : public RefCountableBase
  {
  public:
    typedef RefCountedPtr<T> Ptr;
    typedef RefCountedPtr<const T> ConstPtr;
  };
}

#endif /* !MIMOSA_REF_COUNTABLE_HH */
<commit_msg>Factorized the Ptr and ConstPtr declaration<commit_after>#ifndef MIMOSA_REF_COUNTABLE_HH
# define MIMOSA_REF_COUNTABLE_HH

# include "ref-counted-ptr.hh"

namespace mimosa
{
  class RefCountableBase
  {
  public:
    inline RefCountableBase()
      : ref_count_(0)
    {
    }

    inline RefCountableBase(const RefCountableBase & /*other*/)
      : ref_count_(0)
    {
    }

    virtual ~RefCountableBase() {}

    inline RefCountableBase & operator=(const RefCountableBase & /*other*/)
    {
      return *this;
    }

    inline int addRef() const
    {
      return __sync_add_and_fetch(&ref_count_, 1);
    }

    inline int releaseRef() const
    {
      return __sync_add_and_fetch(&ref_count_, -1);
    }

    mutable int ref_count_;
  };

  inline void addRef(const RefCountableBase * obj)
  {
    obj->addRef();
  }

  inline void releaseRef(const RefCountableBase * obj)
  {
    if (obj->releaseRef() == 0)
      delete obj;
  }

  template <typename T>
  class Ptr
  {
  public:
    typedef RefCountedPtr<T> Ptr;
    typedef RefCountedPtr<const T> ConstPtr;
  };

  template <typename T>
  class RefCountable : public RefCountableBase,
                       public Ptr<T>
  {
  };
}

#endif /* !MIMOSA_REF_COUNTABLE_HH */

{'fraction_non_alphanumeric': 0.10262934690415607, 'fraction_numerical': 0.004240882103477523, 'mean_word_length': 2.8109854604200324, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 15, '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': '1424564', 'n_tokens_mistral': 836, 'n_tokens_neox': 811, 'n_words': 168}