1/*
2 * Copyright �� 2008 Stephan A��mus <superstippi@gmx.de>
3 * All rights reserved. Distributed under the terms of the MIT/X11 license.
4 */
5#ifndef FUNCTION_TRACER_H
6#define FUNCTION_TRACER_H
7
8#include <stdio.h>
9
10#include <String.h>
11
12namespace BPrivate {
13
14class FunctionTracer {
15public:
16	FunctionTracer(const char* className, const char* functionName,
17			int32& depth)
18		: fFunctionName(),
19		  fPrepend(),
20		  fFunctionDepth(depth)
21	{
22		fFunctionDepth++;
23		fPrepend.Append(' ', fFunctionDepth * 2);
24		fFunctionName << className << "::" << functionName << "()";
25
26		printf("%s%s {\n", fPrepend.String(), fFunctionName.String());
27	}
28
29	 ~FunctionTracer()
30	{
31//		printf("%s - leave\n", fFunctionName.String());
32		printf("%s}\n", fPrepend.String());
33		fFunctionDepth--;
34	}
35
36private:
37	BString	fFunctionName;
38	BString	fPrepend;
39	int32&	fFunctionDepth;
40};
41
42}	// namespace BPrivate
43
44using BPrivate::FunctionTracer;
45
46#endif // FUNCTION_TRACER_H
47