ATLAS Offline Software
ArenaAllocatorBase.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 // $Id: ArenaAllocatorBase.cxx 470529 2011-11-24 23:54:22Z ssnyder $
15 #include <ostream>
16 #include <iomanip>
17 
18 
19 namespace SG {
20 
21 
25 // cppcheck-suppress uninitMemberVar ; false positive
27  : inuse (0),
28  free (0),
29  total (0)
30 {
31 }
32 
33 
38 {
39  inuse = free = total = 0;
40 }
41 
42 
49 {
50  inuse += other.inuse;
51  free += other.free;
52  total += other.total;
53  return *this;
54 }
55 
56 
57 /* (hide from doxygen)
58  * @brief Format a statistic structure.
59  * @param os The stream to which to write.
60  * @param stat The statistic structure to write.
61  */
62 std::ostream& operator<< (std::ostream& os,
64 {
65  os << std::setw(7) << stat.inuse << "/"
66  << std::setw(7) << stat.free << "/"
67  << std::setw(7) << stat.total;
68  return os;
69 }
70 
71 
72 //===========================================================================
73 
74 
79 {
80  elts.clear();
81  bytes.clear();
82  blocks.clear();
83 }
84 
85 
92 {
93  elts += other.elts;
94  bytes += other.bytes;
95  blocks += other.blocks;
96  return *this;
97 }
98 
99 
100 /* (hide from doxygen)
101  * @brief Format a complete statistics structure.
102  * @param os The stream to which to write.
103  * @param stats The statistics structure to write.
104  */
105 std::ostream& operator<< (std::ostream& os,
107 {
108  os << stats.elts << " " << stats.bytes << " " << stats.blocks;
109  return os;
110 }
111 
112 
118 {
119  os << "Elts InUse/Free/Total"
120  << " Bytes InUse/Free/Total Blocks InUse/Free/Total";
121 }
122 
123 
124 //===========================================================================
125 
126 
131 void ArenaAllocatorBase::report (std::ostream& os) const
132 {
133  os << " " << stats() << " " << name() << std::endl;
134 }
135 
136 
137 } // namespace SG
SG::ArenaAllocatorBase::stats
virtual Stats stats() const =0
Return the statistics block for this allocator.
SG
Forward declaration.
Definition: CaloCellPacker_400_500.h:32
SG::ArenaAllocatorBase::Stats::blocks
Stat blocks
Counts of blocks.
Definition: ArenaAllocatorBase.h:217
SG::ArenaAllocatorBase::Stats::Stat::clear
void clear()
Reset to zero.
Definition: ArenaAllocatorBase.cxx:37
SG::ArenaAllocatorBase::Stats::Stat
A single statistic.
Definition: ArenaAllocatorBase.h:193
SG::ArenaAllocatorBase::Stats::clear
void clear()
Reset to zero.
Definition: ArenaAllocatorBase.cxx:78
SG::ArenaAllocatorBase::Stats
Statistics for an allocator.
Definition: ArenaAllocatorBase.h:188
SG::ArenaAllocatorBase::Stats::Stat::operator+=
Stat & operator+=(const Stat &other)
Accumulate.
Definition: ArenaAllocatorBase.cxx:48
ArenaAllocatorBase.h
Common base class for arena allocator classes. See Arena.h for an overview of the arena-based memory ...
SG::ArenaAllocatorBase::report
virtual void report(std::ostream &os) const
Generate a report on the memory usage of this allocator.
Definition: ArenaAllocatorBase.cxx:131
beamspotman.stat
stat
Definition: beamspotman.py:266
ReadFromCoolCompare.os
os
Definition: ReadFromCoolCompare.py:231
SG::ArenaAllocatorBase::Stats::bytes
Stat bytes
Counts of bytes.
Definition: ArenaAllocatorBase.h:221
SG::ArenaAllocatorBase::Stats::Stat::Stat
Stat()
Default constructor.
Definition: ArenaAllocatorBase.cxx:26
InDetDD::other
@ other
Definition: InDetDD_Defs.h:16
SG::ArenaAllocatorBase::Stats::header
static void header(std::ostream &os)
Print report header.
Definition: ArenaAllocatorBase.cxx:117
SG::operator<<
std::ostream & operator<<(std::ostream &os, const ArenaAllocatorBase::Stats::Stat &stat)
Format a statistic structure.
Definition: ArenaAllocatorBase.cxx:62
SG::ArenaAllocatorBase::Stats::operator+=
Stats & operator+=(const Stats &other)
Accumulate.
Definition: ArenaAllocatorBase.cxx:91
SG::ArenaAllocatorBase::Stats::elts
Stat elts
Counts of elements.
Definition: ArenaAllocatorBase.h:219
SG::ArenaAllocatorBase::name
virtual const std::string & name() const =0
Return the name of this allocator.