Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

Counter Class Reference

Simple little counter. More...

#include <Counter.h>

List of all members.

Public Member Functions

 Counter ()
bool Add ()
 Returns true progressively less and less often.
void Reset (int count=0)
 Reset the counter.
int GetCount ()
 Get counter's current value;.

Private Attributes

int fCount
int fMult


Detailed Description

Simple little counter.

This maintains a simple counter. To increment the counter call Add(). It's return value can be used to perform some action in a progressively more infrequent manner. It will return true for the first 10 counts, then every 10th count until reaching 100, then every 100th until reaching 1000, etc.

Author:
(last to touch it)
Author
bv
Version:
Revision
1.1
Date:
Date
2005/12/22 17:02:56
Contact: bv@bnl.gov

Created on: Mon Dec 19 18:38:37 2005

Id
Counter.h,v 1.1 2005/12/22 17:02:56 bv Exp

Definition at line 33 of file Counter.h.


Constructor & Destructor Documentation

Counter::Counter  ) 
 

Definition at line 3 of file Counter.cxx.

00003 : fCount(0), fMult(1) {}


Member Function Documentation

bool Counter::Add  ) 
 

Returns true progressively less and less often.

Definition at line 5 of file Counter.cxx.

References fCount, and fMult.

00006 {
00007     ++fCount;
00008     if (fCount>fMult*10) fMult *= 10;
00009     if (fCount%fMult == 0) return true;
00010     return false;
00011 }

int Counter::GetCount  ) 
 

Get counter's current value;.

Definition at line 18 of file Counter.cxx.

00019 {
00020     return fCount;
00021 }

void Counter::Reset int  count = 0  ) 
 

Reset the counter.

Definition at line 12 of file Counter.cxx.

References count, fCount, and fMult.

00013 {
00014     fCount = count;
00015     fMult = 1;
00016     while (count < fMult) fMult *= 10;
00017 }


Member Data Documentation

int Counter::fCount [private]
 

Definition at line 34 of file Counter.h.

Referenced by Add(), and Reset().

int Counter::fMult [private]
 

Definition at line 34 of file Counter.h.

Referenced by Add(), and Reset().


The documentation for this class was generated from the following files:
Generated on Mon Feb 15 11:09:01 2010 for loon by  doxygen 1.3.9.1