TCDelete.h

Go to the documentation of this file.
00001 //*******************************************************************************
00002 //
00003 // *******   ***   ***               *
00004 //    *     *     *                  *
00005 //    *    *      *                *****
00006 //    *    *       ***  *   *   **   *    **    ***
00007 //    *    *          *  * *   *     *   ****  * * *
00008 //    *     *         *   *      *   * * *     * * *
00009 //    *      ***   ***    *     **   **   **   *   *
00010 //                        *
00011 //*******************************************************************************
00012 // see http://sourceforge.net/projects/tcsystem/ for details.
00013 // Copyright (C) 2003 - 2008 Thomas Goessler. All Rights Reserved. 
00014 //*******************************************************************************
00015 //
00016 // TCSystem is the legal property of its developers.
00017 // Please refer to the COPYRIGHT file distributed with this source distribution.
00018 // 
00019 // This library is free software; you can redistribute it and/or             
00020 // modify it under the terms of the GNU Lesser General Public                
00021 // License as published by the Free Software Foundation; either              
00022 // version 2.1 of the License, or (at your option) any later version.        
00023 //                                                                           
00024 // This library is distributed in the hope that it will be useful,           
00025 // but WITHOUT ANY WARRANTY; without even the implied warranty of            
00026 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU         
00027 // Lesser General Public License for more details.                           
00028 //                                                                           
00029 // You should have received a copy of the GNU Lesser General Public          
00030 // License along with this library; if not, write to the Free Software       
00031 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
00032 //*******************************************************************************
00033 //  $Id: TCDelete.h 801 2008-01-23 19:46:25Z the_____tiger $
00034 //*******************************************************************************
00035 #ifndef _TC_DELETE_H_
00036 #define _TC_DELETE_H_
00037 
00038 #include "TCTypes.h"
00039 
00040 namespace TC
00041 {
00062    class Delete
00063    {
00064    public:
00065       template <class T>
00066       void operator()(T* &ptr)
00067       {
00068          delete ptr;
00069          ptr = 0;
00070       }
00071    };
00072 
00077    class CheckedDelete
00078    {
00079    public:
00080       template <class T>
00081       void operator()(T* &ptr)
00082       {
00083          if (ptr) delete ptr;
00084          ptr = 0;
00085       }
00086    };
00087 
00092    class ArrayDelete
00093    {
00094    public:
00095       template <class T>
00096       void operator()(T* &ptr)
00097       {
00098          delete[] ptr;
00099          ptr = 0;
00100       }
00101    };
00102 
00107    class CheckedArrayDelete
00108    {
00109    public:
00110       template <class T>
00111       void operator()(T* &ptr)
00112       {
00113          if (ptr) delete[] ptr;
00114          ptr = 0;
00115       }
00116    };
00117 
00121    class NoDelete
00122    {
00123    public:
00124       template <class T>
00125       void operator()(T* &ptr)
00126       {
00127          ptr = 0;
00128       }
00129    };
00130 
00135 } // namespace TC
00136 
00137 #endif // _TC_DELETE_H_
00138 

Copyright (c) Thomas Goessler 2003 - 2008