<commit_before>/*=========================================================================

  Program:   Insight Segmentation & Registration Toolkit (ITK)
  Module:    itkSmartPointer.h
  Language:  C++
  Date:      $Date$
  Version:   $Revision$


  Copyright (c) 2000 National Library of Medicine
  All rights reserved.

  See COPYRIGHT.txt for copyright details.

=========================================================================*/
#ifndef __itkSmartPointer_h
#define __itkSmartPointer_h

#include "itkMacro.h"
#include <iostream>

namespace itk
{

/** \class SmartPointer
 * \brief Implements transparent reference counting.
 *
 * SmartPointer implements reference counting by overloading
 * operator -> (and *) among others. This allows natural interface
 * to the class referred to by the pointer without having to invoke
 * special Register()/UnRegister() methods directly.
 *
 * To compile / test this class
 * Windows: cl SmartPointerTest.cxx; .\SmartPointerTest.exe
 * linux:   c++ SmartPointerTest.cxx ./a.out
 * other:   CCcompiler SmartPointerTest.cxx  ./a.out
 */
template <class TObjectType>
class ITK_EXPORT SmartPointer 
{
public:
  typedef TObjectType ObjectType;
  
  /** 
   * Constructor 
   */
  SmartPointer () 
    {
    m_Pointer = 0;
    }

  /** 
   * Copy constructor 
   */
  SmartPointer (const SmartPointer<ObjectType> &p):
    m_Pointer(p.m_Pointer)
    { 
    this->Register(); 
    }
  
  /** 
   * Constructor to pointer p 
   */
  SmartPointer (ObjectType *p):
    m_Pointer(p)
    { 
    this->Register(); 
    }                             
  
  /** 
   * Destructor 
   */
  ~SmartPointer ()
    {
    this->UnRegister();
    }
  
  /** <commit_msg>FIX: zero of m_Pointer in destructor<commit_after>/*=========================================================================

  Program:   Insight Segmentation & Registration Toolkit (ITK)
  Module:    itkSmartPointer.h
  Language:  C++
  Date:      $Date$
  Version:   $Revision$


  Copyright (c) 2000 National Library of Medicine
  All rights reserved.

  See COPYRIGHT.txt for copyright details.

=========================================================================*/
#ifndef __itkSmartPointer_h
#define __itkSmartPointer_h

#include "itkMacro.h"
#include <iostream>

namespace itk
{

/** \class SmartPointer
 * \brief Implements transparent reference counting.
 *
 * SmartPointer implements reference counting by overloading
 * operator -> (and *) among others. This allows natural interface
 * to the class referred to by the pointer without having to invoke
 * special Register()/UnRegister() methods directly.
 *
 * To compile / test this class
 * Windows: cl SmartPointerTest.cxx; .\SmartPointerTest.exe
 * linux:   c++ SmartPointerTest.cxx ./a.out
 * other:   CCcompiler SmartPointerTest.cxx  ./a.out
 */
template <class TObjectType>
class ITK_EXPORT SmartPointer 
{
public:
  typedef TObjectType ObjectType;
  
  /** 
   * Constructor 
   */
  SmartPointer () 
    {
    m_Pointer = 0;
    }

  /** 
   * Copy constructor 
   */
  SmartPointer (const SmartPointer<ObjectType> &p):
    m_Pointer(p.m_Pointer)
    { 
    this->Register(); 
    }
  
  /** 
   * Constructor to pointer p 
   */
  SmartPointer (ObjectType *p):
    m_Pointer(p)
    { 
    this->Register(); 
    }                             
  
  /** 
   * Destructor 
   */
  ~SmartPointer ()
    {
    this->UnRegister();
    m_Pointer = 0;  
    }
  
  /** 
{'fraction_non_alphanumeric': 0.18131548311990686, 'fraction_numerical': 0.0032013969732246797, 'mean_word_length': 2.9826187717265356, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 17, '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': '5691065', 'n_tokens_mistral': 1051, 'n_tokens_neox': 965, 'n_words': 263}