Xalan-C++ API Documentation

The Xalan C++ XSLT Processor Version 1.10

XalanDiagnosticMemoryManager.hpp
Go to the documentation of this file.
1 /*
2  * Copyright 1999-2005 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 #if !defined(XALAN_DIAGNOSTICMEMORYMANAGER_HEADER_GUARD_1357924680)
17 #define XALAN_DIAGNOSTICMEMORYMANAGER_HEADER_GUARD_1357924680
18 
19 
20 
22 
23 
24 
25 #include <cstddef>
26 
27 
28 
29 #if defined(XALAN_CLASSIC_IOSTREAMS)
30 #include <iostream.h>
31 #else
32 #include <iosfwd>
33 #include <ios>
34 #endif
35 
36 
37 
38 #include "xercesc/framework/MemoryManager.hpp"
39 
40 
41 
43 
44 
45 
46 XALAN_CPP_NAMESPACE_BEGIN
47 
48 
49 
50 XALAN_USING_XERCES(MemoryManager)
51 
52 
53 
55 {
56 public:
57 
58  typedef unsigned int int_type;
59 
60 #if defined(XALAN_NO_STD_NAMESPACE)
61  typedef ostream StreamType;
62 #else
63  typedef std::ostream StreamType;
64 #endif
65 
66 #if defined(XALAN_STRICT_ANSI_HEADERS)
67  typedef std::size_t size_type;
68 #else
69  typedef size_t size_type;
70 #endif
71 
73  {
74  public:
75 
77  {
78  }
79 
81  {
82  }
83  };
84 
86  MemoryManager& theMemoryManager,
87  bool fAssertErrors = false,
88  StreamType* theStream = 0);
89 
90  virtual
92 
93  virtual void*
94  allocate(size_type size);
95 
96  virtual void
97  deallocate(void* pointer);
98 
99  bool
101  {
102  return m_assertErrors;
103  }
104 
105  void
106  setAssertErrors(bool fFlag)
107  {
108  m_assertErrors = fFlag;
109  }
110 
111  // Get the high-water mark (the highest amount
112  // that was allocated at any particular point).
113  size_type
115  {
116  return m_highWaterMark;
117  }
118 
119  // Get the number of bytes currently allocated.
120  size_type
121  getAllocated() const
122  {
123  return m_currentAllocated;
124  }
125 
126  // Get the current number of outstanding allocations.
127  size_type
129  {
130  return m_allocations.size();
131  }
132 
133  struct Data
134  {
135  Data() :
136  m_size(0),
137  m_sequence(0)
138  {
139  }
140 
142  size_type theSize,
143  size_type theSequence) :
144  m_size(theSize),
145  m_sequence(theSequence)
146  {
147  }
148 
149  size_type m_size;
150 
151  size_type m_sequence;
152  };
153 
155 
157 
158  const_iterator
160  {
161  return m_allocations.begin();
162  }
163 
164  void
166  {
167  m_locked = true;
168  }
169 
170  void
172  {
173  m_locked = false;
174  }
175 
176  enum
177  {
178  defaultBytesToDump = 20u
179  };
180 
181  void
182  dumpStatistics(
183  StreamType* theStream = 0,
184  size_type theBytesToDump = defaultBytesToDump);
185 
186 private:
187 
189 
191  operator=(const XalanDiagnosticMemoryManager&);
192 
193  MemoryManager& m_memoryManager;
194 
195  bool m_assertErrors;
196 
197  bool m_locked;
198 
199  size_type m_sequence;
200 
201  size_type m_highWaterMark;
202 
203  size_type m_currentAllocated;
204 
205  MapType m_allocations;
206 
207  StreamType* m_stream;
208 };
209 
210 
211 
212 XALAN_CPP_NAMESPACE_END
213 
214 
215 
216 #endif // XALAN_DIAGNOSTICMEMORYMANAGER_HEADER_GUARD_1357924680
size_type m_sequence
Definition: XalanDiagnosticMemoryManager.hpp:151
unsigned int int_type
Definition: XalanDiagnosticMemoryManager.hpp:58
#define XALAN_HARNESS_EXPORT
Definition: XalanHarnessDefinitions.hpp:25
size_t size_type
Definition: XalanDiagnosticMemoryManager.hpp:69
Definition: XalanDiagnosticMemoryManager.hpp:54
Definition: XalanDiagnosticMemoryManager.hpp:133
Data()
Definition: XalanDiagnosticMemoryManager.hpp:135
size_type getAllocations() const
Definition: XalanDiagnosticMemoryManager.hpp:128
size_type m_size
Definition: XalanDiagnosticMemoryManager.hpp:149
Definition: XalanMap.hpp:113
void lock()
Definition: XalanDiagnosticMemoryManager.hpp:165
size_type getHighWaterMark() const
Definition: XalanDiagnosticMemoryManager.hpp:114
XALAN_CPP_NAMESPACE_BEGIN typedef size_t size_type
Definition: XalanMap.hpp:44
void unlock()
Definition: XalanDiagnosticMemoryManager.hpp:171
bool getAssertErrors() const
Definition: XalanDiagnosticMemoryManager.hpp:100
std::ostream StreamType
Definition: XalanDiagnosticMemoryManager.hpp:63
const_iterator getAllocationsIterator() const
Definition: XalanDiagnosticMemoryManager.hpp:159
Data(size_type theSize, size_type theSequence)
Definition: XalanDiagnosticMemoryManager.hpp:141
XalanMap< void *, Data > MapType
Definition: XalanDiagnosticMemoryManager.hpp:154
Definition: XalanDiagnosticMemoryManager.hpp:72
void setAssertErrors(bool fFlag)
Definition: XalanDiagnosticMemoryManager.hpp:106
size_type getAllocated() const
Definition: XalanDiagnosticMemoryManager.hpp:121
MapType::const_iterator const_iterator
Definition: XalanDiagnosticMemoryManager.hpp:156
~LockException()
Definition: XalanDiagnosticMemoryManager.hpp:80
LockException()
Definition: XalanDiagnosticMemoryManager.hpp:76

Interpreting class diagrams

Doxygen and GraphViz are used to generate this API documentation from the Xalan-C header files.

dot

Xalan-C++ XSLT Processor Version 1.10
Copyright © 1999-2004 The Apache Software Foundation. All Rights Reserved.

Apache Logo