3 // Copyright (C) 2005, 2006 Free Software Foundation, Inc.
5 // This file is part of the GNU ISO C++ Library. This library is free
6 // software; you can redistribute it and/or modify it under the terms
7 // of the GNU General Public License as published by the Free Software
8 // Foundation; either version 2, or (at your option) any later
11 // This library is distributed in the hope that it will be useful, but
12 // WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this library; see the file COPYING. If not, write to
18 // the Free Software Foundation, 59 Temple Place - Suite 330, Boston,
19 // MA 02111-1307, USA.
21 // As a special exception, you may use this file as part of a free
22 // software library without restriction. Specifically, if other files
23 // instantiate templates or use macros or inline functions from this
24 // file, or you compile this file and link it with other files to
25 // produce an executable, this file does not by itself cause the
26 // resulting executable to be covered by the GNU General Public
27 // License. This exception does not however invalidate any other
28 // reasons why the executable file might be covered by the GNU General
31 // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
33 // Permission to use, copy, modify, sell, and distribute this software
34 // is hereby granted without fee, provided that the above copyright
35 // notice appears in all copies, and that both that copyright notice
36 // and this permission notice appear in supporting documentation. None
37 // of the above authors, nor IBM Haifa Research Laboratories, make any
38 // representation about the suitability of this software for any
39 // purpose. It is provided "as is" without express or implied
43 * @file tree_trace_base.hpp
44 * Contains tree-related policies.
47 #ifndef PB_DS_TREE_TRACE_BASE_HPP
48 #define PB_DS_TREE_TRACE_BASE_HPP
50 #ifdef PB_DS_TREE_TRACE
52 #include <ext/pb_ds/detail/basic_tree_policy/basic_tree_policy_base.hpp>
53 #include <ext/pb_ds/detail/basic_tree_policy/null_node_metadata.hpp>
61 #ifdef PB_DS_TREE_TRACE
63 #define PB_DS_CLASS_T_DEC \
65 class Const_Node_Iterator, \
66 class Node_Iterator, \
71 #define PB_DS_CLASS_C_DEC \
73 Const_Node_Iterator, \
79 #define PB_DS_BASE_C_DEC \
80 basic_tree_policy_base< \
81 Const_Node_Iterator, \
85 template<typename Const_Node_Iterator,
90 class tree_trace_base : private PB_DS_BASE_C_DEC
97 typedef PB_DS_BASE_C_DEC base_type;
99 typedef Const_Node_Iterator const_node_iterator;
101 typedef typename Allocator::size_type size_type;
105 trace_node(const_node_iterator nd_it, size_type level) const;
110 virtual const_node_iterator
111 node_begin() const = 0;
113 virtual const_node_iterator
114 node_end() const = 0;
117 print_node_pointer(Const_Node_Iterator nd_it, integral_constant<int,true>);
120 print_node_pointer(Const_Node_Iterator nd_it, integral_constant<int,false>);
122 template<typename Metadata_>
124 trace_it_metadata(Const_Node_Iterator nd_it, type_to_type<Metadata_>);
127 trace_it_metadata(Const_Node_Iterator, type_to_type<null_node_metadata>);
138 trace_node(node_begin(), 0);
144 trace_node(const_node_iterator nd_it, size_type level) const
146 if (nd_it.get_r_child() != node_end())
147 trace_node(nd_it.get_r_child(), level + 1);
149 for (size_type i = 0; i < level; ++i)
152 print_node_pointer(nd_it, integral_constant<int,Node_Based>());
153 std::cerr << base_type::extract_key(*(*nd_it));
157 typename const_node_iterator::metadata_type>
160 trace_it_metadata(nd_it, m_type_ind_t());
162 std::cerr << std::endl;
164 if (nd_it.get_l_child() != node_end())
165 trace_node(nd_it.get_l_child(), level + 1);
169 template<typename Metadata_>
172 trace_it_metadata(Const_Node_Iterator nd_it, type_to_type<Metadata_>)
175 static_cast<unsigned long>(nd_it.get_metadata()) << ") ";
181 trace_it_metadata(Const_Node_Iterator, type_to_type<null_node_metadata>)
187 print_node_pointer(Const_Node_Iterator nd_it, integral_constant<int,true>)
189 std::cerr << nd_it.m_p_nd << " ";
195 print_node_pointer(Const_Node_Iterator nd_it, integral_constant<int,false>)
197 std::cerr <<* nd_it << " ";
200 #undef PB_DS_CLASS_T_DEC
202 #undef PB_DS_CLASS_C_DEC
204 #undef PB_DS_BASE_C_DEC
206 #endif // #ifdef PB_DS_TREE_TRACE
208 } // namespace detail
212 #endif // #ifdef PB_DS_TREE_TRACE
214 #endif // #ifndef PB_DS_TREE_TRACE_BASE_HPP