dump_sharedheap.h 2.81 KB
Newer Older
thomas.forbriger's avatar
thomas.forbriger committed
1
2
3
4
5
/*! \file dump_sharedheap.h
 * \brief factored out SharedHeap dump function (prototypes)
 * 
 * ----------------------------------------------------------------------------
 * 
thomas.forbriger's avatar
thomas.forbriger committed
6
 * $Id: dump_sharedheap.h,v 1.4 2006/03/28 16:03:06 tforb Exp $
thomas.forbriger's avatar
thomas.forbriger committed
7
8
9
10
11
 * \author Thomas Forbriger
 * \date 19/12/2002
 * 
 * factored out SharedHeap dump function (prototypes)
 *
thomas.forbriger's avatar
thomas.forbriger committed
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
 * ----
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version. 
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 * ----
 *
thomas.forbriger's avatar
thomas.forbriger committed
28
29
30
31
32
33
 * \ingroup group_helpers
 * 
 * Copyright (c) 2002 by Thomas Forbriger (IMG Frankfurt) 
 * 
 * REVISIONS and CHANGES 
 *  - 19/12/2002   V1.0   Thomas Forbriger
thomas.forbriger's avatar
thomas.forbriger committed
34
35
36
 *  - 28/12/2002   V1.1   (thof)
 *                        - functions now take ConstSharedHeap class reference
 *                          arguments
thomas.forbriger's avatar
thomas.forbriger committed
37
38
 *  - 03/01/2003   V1.2   (thof)
 *                        - distinguish more clearly between size and values
thomas.forbriger's avatar
thomas.forbriger committed
39
40
41
42
43
44
45
46
 * 
 * ============================================================================
 */

// include guard
#ifndef AFF_DUMP_SHAREDHEAP_H_VERSION

#define AFF_DUMP_SHAREDHEAP_H_VERSION \
thomas.forbriger's avatar
thomas.forbriger committed
47
  "AFF_DUMP_SHAREDHEAP_H   V1.2"
thomas.forbriger's avatar
thomas.forbriger committed
48
#define AFF_DUMP_SHAREDHEAP_H_CVSID \
thomas.forbriger's avatar
thomas.forbriger committed
49
  "$Id: dump_sharedheap.h,v 1.4 2006/03/28 16:03:06 tforb Exp $"
thomas.forbriger's avatar
thomas.forbriger committed
50
51
52
53
54
55
56
57
58
59
60
61
62

#include<iostream>
#include<aff/lib/sharedheap.h>

namespace aff {

using std::endl;

/*! \brief Dump heap layout 
 *
 * \ingroup group_helpers
 */
template<typename T>
thomas.forbriger's avatar
thomas.forbriger committed
63
void dump_layout(const aff::ConstSharedHeap<T>& sharedheap, 
thomas.forbriger's avatar
thomas.forbriger committed
64
65
          std::ostream& os=std::cout)
{
thomas.forbriger's avatar
thomas.forbriger committed
66
67
  os << "  SharedHeap object size: "
   << sharedheap.size() << " elements" << endl;
thomas.forbriger's avatar
thomas.forbriger committed
68
69
70
71
72
73
74
75
76
}

/*----------------------------------------------------------------------*/

/*! \brief Dump heap contents 
 *
 * \ingroup group_helpers
 */
template<typename T>
thomas.forbriger's avatar
thomas.forbriger committed
77
void dump(const aff::ConstSharedHeap<T>& sharedheap, 
thomas.forbriger's avatar
thomas.forbriger committed
78
79
          std::ostream& os=std::cout)
{
thomas.forbriger's avatar
thomas.forbriger committed
80
  os << "dump of SharedHeap object:" << endl;
thomas.forbriger's avatar
thomas.forbriger committed
81
  dump_layout(sharedheap, os);
thomas.forbriger's avatar
thomas.forbriger committed
82
  os << "  element values:" << endl;
thomas.forbriger's avatar
thomas.forbriger committed
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
  int i=0;
  for (aff::Tsize k=0; k<sharedheap.size(); k++)
  {
    if (!i) { os << "   "; }
    os.width(8);
    os << sharedheap[k] << " ";
    if (++i>7) { i=0; os << endl; }
  }
  os << endl;
}

} // namespace aff

#endif // AFF_DUMP_SHAREDHEAP_H_VERSION (includeguard)

/* ----- END OF dump_sharedheap.h ----- */