00001 /* 00002 * Licensed to the Apache Software Foundation (ASF) under one 00003 * or more contributor license agreements. See the NOTICE file 00004 * distributed with this work for additional information 00005 * regarding copyright ownership. The ASF licenses this file 00006 * to you under the Apache License, Version 2.0 (the "License"); 00007 * you may not use this file except in compliance with the License. 00008 * You may obtain a copy of the License at 00009 * 00010 * http://www.apache.org/licenses/LICENSE-2.0 00011 * 00012 * Unless required by applicable law or agreed to in writing, software 00013 * distributed under the License is distributed on an "AS IS" BASIS, 00014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00015 * See the License for the specific language governing permissions and 00016 * limitations under the License. 00017 */ 00018 #if !defined(XALAN_DIAGNOSTICMEMORYMANAGER_HEADER_GUARD_1357924680) 00019 #define XALAN_DIAGNOSTICMEMORYMANAGER_HEADER_GUARD_1357924680 00020 00021 00022 00023 #include "xalanc/Harness/XalanHarnessDefinitions.hpp" 00024 00025 00026 00027 #include <cstddef> 00028 00029 00030 00031 #if defined(XALAN_CLASSIC_IOSTREAMS) 00032 #include <iostream.h> 00033 #else 00034 #include <iosfwd> 00035 #include <ios> 00036 #endif 00037 00038 00039 00040 #include "xalanc/Include/XalanMap.hpp" 00041 #include "xalanc/Include/XalanMemoryManagement.hpp" 00042 00043 00044 00045 XALAN_CPP_NAMESPACE_BEGIN 00046 00047 00048 00049 class XALAN_HARNESS_EXPORT XalanDiagnosticMemoryManager : public XalanMemoryManager 00050 { 00051 public: 00052 00053 #if defined(XALAN_NO_STD_NAMESPACE) 00054 typedef ostream StreamType; 00055 #else 00056 typedef std::ostream StreamType; 00057 #endif 00058 00059 class LockException 00060 { 00061 public: 00062 00063 LockException() 00064 { 00065 } 00066 00067 ~LockException() 00068 { 00069 } 00070 }; 00071 00072 XalanDiagnosticMemoryManager( 00073 MemoryManager& theMemoryManager, 00074 bool fAssertErrors = false, 00075 StreamType* theStream = 0); 00076 00077 virtual 00078 ~XalanDiagnosticMemoryManager(); 00079 00080 virtual void* 00081 allocate(size_type size); 00082 00083 virtual void 00084 deallocate(void* pointer); 00085 00086 virtual MemoryManager* 00087 getExceptionMemoryManager(); 00088 00089 bool 00090 getAssertErrors() const 00091 { 00092 return m_assertErrors; 00093 } 00094 00095 void 00096 setAssertErrors(bool fFlag) 00097 { 00098 m_assertErrors = fFlag; 00099 } 00100 00101 // Get the high-water mark (the highest amount 00102 // that was allocated at any particular point). 00103 size_type 00104 getHighWaterMark() const 00105 { 00106 return m_highWaterMark; 00107 } 00108 00109 // Get the number of bytes currently allocated. 00110 size_type 00111 getAllocated() const 00112 { 00113 return m_currentAllocated; 00114 } 00115 00116 // Get the current number of outstanding allocations. 00117 size_type 00118 getAllocations() const 00119 { 00120 return m_allocations.size(); 00121 } 00122 00123 struct Data 00124 { 00125 Data() : 00126 m_size(0), 00127 m_sequence(0) 00128 { 00129 } 00130 00131 Data( 00132 size_type theSize, 00133 size_type theSequence) : 00134 m_size(theSize), 00135 m_sequence(theSequence) 00136 { 00137 } 00138 00139 size_type m_size; 00140 00141 size_type m_sequence; 00142 }; 00143 00144 typedef XalanMap<void*, Data> MapType; 00145 00146 typedef MapType::const_iterator const_iterator; 00147 00148 const_iterator 00149 getAllocationsIterator() const 00150 { 00151 return m_allocations.begin(); 00152 } 00153 00154 void 00155 lock() 00156 { 00157 m_locked = true; 00158 } 00159 00160 void 00161 unlock() 00162 { 00163 m_locked = false; 00164 } 00165 00166 enum 00167 { 00168 defaultBytesToDump = 20u 00169 }; 00170 00171 void 00172 dumpStatistics( 00173 StreamType* theStream = 0, 00174 size_type theBytesToDump = defaultBytesToDump); 00175 00176 private: 00177 00178 XalanDiagnosticMemoryManager(const XalanDiagnosticMemoryManager&); 00179 00180 XalanDiagnosticMemoryManager& 00181 operator=(const XalanDiagnosticMemoryManager&); 00182 00183 MemoryManager& m_memoryManager; 00184 00185 bool m_assertErrors; 00186 00187 bool m_locked; 00188 00189 size_type m_sequence; 00190 00191 size_type m_highWaterMark; 00192 00193 size_type m_currentAllocated; 00194 00195 MapType m_allocations; 00196 00197 StreamType* m_stream; 00198 }; 00199 00200 00201 00202 XALAN_CPP_NAMESPACE_END 00203 00204 00205 00206 #endif // XALAN_DIAGNOSTICMEMORYMANAGER_HEADER_GUARD_1357924680
Doxygen and GraphViz are used to generate this API documentation from the Xalan-C header files.
Xalan-C++ XSLT Processor Version 1.11 |
|