xref: /trunk/main/sw/source/core/inc/dbgloop.hxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef _DBGLOOP_HXX
29 #define _DBGLOOP_HXX
30 
31 #ifdef DBG_UTIL
32 
33 #include <tools/solar.h>
34 
35 class SvStream;
36 
37 #define DBG_MAX_STACK	20		// Verschachtelungstiefe
38 #define DBG_MAX_LOOP  1000		// das Abbruchkriterium
39 
40 class DbgLoopStack
41 {
42 	sal_uInt16 aCount[DBG_MAX_STACK];
43 	sal_uInt16 nPtr;
44 	const void *pDbg;
45 	void Reset();
46 public:
47 	DbgLoopStack();
48 	void Push( const void *pThis );
49 	void Pop();
50 	void Print( SvStream &rOS ) const; //$ ostream
51 };
52 
53 class DbgLoop
54 {
55 	friend inline void PrintLoopStack( SvStream &rOS ); //$ ostream
56 	static DbgLoopStack aDbgLoopStack;
57 public:
58 	inline DbgLoop( const void *pThis ) { aDbgLoopStack.Push( pThis ); }
59 	inline ~DbgLoop() { aDbgLoopStack.Pop(); }
60 };
61 
62 inline void PrintLoopStack( SvStream &rOS ) //$ ostream
63 {
64 	DbgLoop::aDbgLoopStack.Print( rOS );
65 }
66 
67 #define DBG_LOOP	DbgLoop aDbgLoop( (const void*)this );
68 #define DBG_LOOP_RESET	DbgLoop aDbgLoop( 0 );
69 
70 #else
71 
72 #define DBG_LOOP
73 #define DBG_LOOP_RESET
74 
75 #endif
76 
77 #endif
78