// -*- C++ -*- /* Copyright 1996 * Wed May 28 10:42:33 1997 Brian Edward Smits (bes@phoenix.cs.utah.edu) * * RiCounter.H * * * * $Id: RiCounter.H,v 1.3 1998/10/30 22:11:03 bes Exp $ * */ #ifndef RICOMMON_H #include #endif /********************************************************** //// This #define can be set in Makefile.user as either 0 or 1 // to control whether or not counters are actually used. // hopefully, with RI_USE_COUNTERS set to 0 there is no overhead for counters // // bool RI_NO_COUNTERS // ********************************************************/ /*************************************************************** CLASS RiCounter A counter that prints it's value when it goes out of scope. DESCRIPTION ****************************************************************/ class RiCounter { public: // GROUP: Constructors and assignment //// Default Constructor RiCounter(char *label, unsigned long ival = 0); //// Destructor ~RiCounter(); // GROUP: Accessors //// Return the current value of the counter. long long GetValue(); // GROUP: Members //// increment void operator++(int); //// add to the counter void operator+=(int num); private: #ifndef RI_NO_COUNTERS char label[80]; long long val; #endif }; inline long long RiCounter::GetValue() { #ifndef RI_NO_COUNTERS return val; #endif } inline void RiCounter::operator++(int) { #ifndef RI_NO_COUNTERS val++; #endif } inline void RiCounter::operator+=(int num) { #ifndef RI_NO_COUNTERS val+=num; #endif }