cond_key_dtor_entry_dealtor.hpp revision 169691
192108Sphk// -*- C++ -*-
292108Sphk
392108Sphk// Copyright (C) 2005, 2006 Free Software Foundation, Inc.
492108Sphk//
592108Sphk// This file is part of the GNU ISO C++ Library.  This library is free
692108Sphk// software; you can redistribute it and/or modify it under the terms
792108Sphk// of the GNU General Public License as published by the Free Software
892108Sphk// Foundation; either version 2, or (at your option) any later
992108Sphk// version.
1092108Sphk
1192108Sphk// This library is distributed in the hope that it will be useful, but
1292108Sphk// WITHOUT ANY WARRANTY; without even the implied warranty of
1392108Sphk// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
1492108Sphk// General Public License for more details.
1592108Sphk
1692108Sphk// You should have received a copy of the GNU General Public License
1792108Sphk// along with this library; see the file COPYING.  If not, write to
1892108Sphk// the Free Software Foundation, 59 Temple Place - Suite 330, Boston,
1992108Sphk// MA 02111-1307, USA.
2092108Sphk
2192108Sphk// As a special exception, you may use this file as part of a free
2292108Sphk// software library without restriction.  Specifically, if other files
2392108Sphk// instantiate templates or use macros or inline functions from this
2492108Sphk// file, or you compile this file and link it with other files to
2592108Sphk// produce an executable, this file does not by itself cause the
2692108Sphk// resulting executable to be covered by the GNU General Public
2792108Sphk// License.  This exception does not however invalidate any other
2892108Sphk// reasons why the executable file might be covered by the GNU General
2992108Sphk// Public License.
3092108Sphk
3192108Sphk// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
3292108Sphk
3392108Sphk// Permission to use, copy, modify, sell, and distribute this software
3492108Sphk// is hereby granted without fee, provided that the above copyright
3592108Sphk// notice appears in all copies, and that both that copyright notice
36116196Sobrien// and this permission notice appear in supporting documentation. None
37116196Sobrien// of the above authors, nor IBM Haifa Research Laboratories, make any
38116196Sobrien// representation about the suitability of this software for any
3992108Sphk// purpose. It is provided "as is" without express or implied
4092108Sphk// warranty.
4192108Sphk
42113926Sphk/**
4392108Sphk * @file cond_key_dtor_entry_dealtor.hpp
4492108Sphk * Contains a binary tree container conditional deallocator
4592108Sphk */
4692108Sphk
4792108Sphkclass bin_seach_tree_cond_key_dtor_entry_dealtor_
4892108Sphk{
4992108Sphkpublic:
50139451Sjhb  inline
51139451Sjhb  bin_seach_tree_cond_key_dtor_entry_dealtor_(node_pointer p_nd) : m_p_nd(p_nd),
5292108Sphk								   m_no_action_dtor(false),
5392108Sphk								   m_key_destruct(false)
5493250Sphk  { }
5592108Sphk
5692108Sphk  inline void
5792108Sphk  set_no_action_dtor()
5892108Sphk  {
5992108Sphk    m_no_action_dtor = true;
6092108Sphk  }
6192108Sphk
6292108Sphk  inline void
63110592Sphk  set_key_destruct()
64113926Sphk  {
6592108Sphk    m_key_destruct = true;
66104063Sphk  }
67104063Sphk
68104063Sphk  inline
69104063Sphk  ~bin_seach_tree_cond_key_dtor_entry_dealtor_()
70104063Sphk  {
71104063Sphk    if (m_no_action_dtor)
72104063Sphk      return;
73104063Sphk
74104063Sphk    if (m_key_destruct)
75104063Sphk      m_p_nd->m_value.first.~Key();
76104063Sphk
77104063Sphk    bin_tree_base::s_alloc.deallocate(m_p_nd, 1);
78104063Sphk  }
79104063Sphk
80104063Sphkprotected:
81104063Sphk  node_pointer m_p_nd;
82104063Sphk
83104063Sphk  bool m_no_action_dtor;
8492108Sphk
8592108Sphk  bool m_key_destruct;
8692108Sphk};
8792108Sphk
8899028Sjulian