convert line ends
[canaan.git] / prj / cam / src / object / propinst.h
blob1f70005178e5f588ff6b3db75fd31a322d203472
1 /*
2 @Copyright Looking Glass Studios, Inc.
3 1996,1997,1998,1999,2000 Unpublished Work.
4 */
6 // $Header: r:/t2repos/thief2/src/object/propinst.h,v 1.1 1998/10/01 18:40:38 mahk Exp $
7 #pragma once
8 #ifndef __PROPINST_H
9 #define __PROPINST_H
11 ////////////////////////////////////////////////////////////
12 // PROPERTY MEMORY INSTRUMENTATION
15 #ifdef PROPERTY_BLAME
18 // copy the name into a static buffer, return a pointer to
19 // be used for blaming
21 EXTERN const char* PropBlameName(const char* name);
22 #define PROP_BLAME_NAME(x) PropBlameName(x)
25 // Push property blame
27 EXTERN void PropPushBlame(const char* name);
28 #define PROP_PUSH_BLAME(x) PropPushBlame(x)
31 // Pop property blame
33 EXTERN void PropPopBlame(void);
34 #define PROP_POP_BLAME() PropPopBlame()
36 class cPropAutoBlamer
38 public:
39 cPropAutoBlamer(const char* s)
41 PropPushBlame(s);
44 ~cPropAutoBlamer()
46 PropPopBlame();
50 #define PROP_AUTO_BLAME(s) cPropAutoBlamer blamer__(s)
52 #else // !PROPERTY_BLAME
54 #define PROP_BLAME_NAME(x) (x)
55 #define PROP_PUSH_BLAME(x)
56 #define PROP_POP_BLAME()
57 #define PROP_AUTO_BLAME(x)
59 #endif // !PROPERTY_BLAME
61 EXTERN BOOL gBlameProperties;
64 ////////////////////////////////////////////////////////////
65 // PROPERTY TIME INSTRUMENTATION
68 #ifdef PROPERTY_TIME
70 class cPropTimer
72 protected:
73 ulong* mpStat;
74 ulong* mpStatBack;
75 long start;
77 static ulong gDummyStat;
79 static long GetTime();
81 public:
83 void Start()
85 start = GetTime();
86 mpStat = mpStatBack;
89 void Stop()
91 *mpStat += GetTime() - start;
92 mpStat = &gDummyStat;
95 void Restart(ulong* pstat)
97 mpStatBack = pstat;
98 Start();
101 cPropTimer(ulong* pstat)
102 : mpStatBack(pstat)
104 Start();
108 ~cPropTimer()
110 Stop();
116 // MACROS FOR CREATING TIMERS
119 #define PROP_TIMER_ULONG_PTR(x) cPropTimer prop_timer__(x)
120 #define PROP_TIMER_STATS_IDX(s,i) PROP_TIMER_ULONG_PTR((ulong*)&(s).time[i])
121 #define PROP_TIMER_STOP() prop_timer__.Stop()
122 #define PROP_TIMER_START() prop_timer__.Start()
123 #define PROP_TIMER_RESTART_STATS_IDX(s,i) prop_timer__.Restart((ulong*)&(s).time[i])
126 #else // !PROPERTY_TIME
128 #define PROP_TIMER_ULONG_PTR(x)
129 #define PROP_TIMER_STATS_IDX(s,i)
130 #define PROP_TIMER_STOP()
131 #define PROP_TIMER_START()
132 #define PROP_TIMER_RESTART_STATS_IDX(s,i)
134 #endif // !PROPERTY_TIME
136 #endif // __PROPINST_H