xref: /aoo4110/main/sw/source/core/inc/dbgloop.hxx (revision b1cdbd2c)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef _DBGLOOP_HXX
25 #define _DBGLOOP_HXX
26 
27 #ifdef DBG_UTIL
28 
29 #include <tools/solar.h>
30 
31 class SvStream;
32 
33 #define DBG_MAX_STACK	20		// Verschachtelungstiefe
34 #define DBG_MAX_LOOP  1000		// das Abbruchkriterium
35 
36 class DbgLoopStack
37 {
38 	sal_uInt16 aCount[DBG_MAX_STACK];
39 	sal_uInt16 nPtr;
40 	const void *pDbg;
41 	void Reset();
42 public:
43 	DbgLoopStack();
44 	void Push( const void *pThis );
45 	void Pop();
46 	void Print( SvStream &rOS ) const; //$ ostream
47 };
48 
49 class DbgLoop
50 {
51 	friend inline void PrintLoopStack( SvStream &rOS ); //$ ostream
52 	static DbgLoopStack aDbgLoopStack;
53 public:
DbgLoop(const void * pThis)54 	inline DbgLoop( const void *pThis ) { aDbgLoopStack.Push( pThis ); }
~DbgLoop()55 	inline ~DbgLoop() { aDbgLoopStack.Pop(); }
56 };
57 
PrintLoopStack(SvStream & rOS)58 inline void PrintLoopStack( SvStream &rOS ) //$ ostream
59 {
60 	DbgLoop::aDbgLoopStack.Print( rOS );
61 }
62 
63 #define DBG_LOOP	DbgLoop aDbgLoop( (const void*)this );
64 #define DBG_LOOP_RESET	DbgLoop aDbgLoop( 0 );
65 
66 #else
67 
68 #define DBG_LOOP
69 #define DBG_LOOP_RESET
70 
71 #endif
72 
73 #endif
74