ESyS-Particle  4.0.1
Counter.h
00001 
00002 //                                                         //
00003 // Copyright (c) 2003-2011 by The University of Queensland //
00004 // Earth Systems Science Computational Centre (ESSCC)      //
00005 // http://www.uq.edu.au/esscc                              //
00006 //                                                         //
00007 // Primary Business: Brisbane, Queensland, Australia       //
00008 // Licensed under the Open Software License version 3.0    //
00009 // http://www.opensource.org/licenses/osl-3.0.php          //
00010 //                                                         //
00012 
00013 #ifndef _COUNTER_H_
00014 #define _COUNTER_H_
00015 #include "t_list.h"
00016 
00017 //--- IO includes ---
00018 #include <iostream>
00019 #include <cstdio>
00020 using std::ostream;
00021 
00022 //--- system includes ---
00023 #include <string.h>
00024 
00029 class CCounter {
00030 protected:
00031     char *Name ; 
00032     int Value ; 
00033     int Id ;
00034 public:
00035     CCounter() ;
00036     CCounter(char *Name, int Id=0) ;
00037     virtual ~CCounter() ;
00038 
00039     void create(char *Name, int Id=0) ; 
00040     CCounter & operator +=(int n) ;     
00041     CCounter & operator -=(int n) ;     
00042     CCounter & operator ++() ;          
00043     CCounter & operator --() ;          
00044     CCounter & operator ++(int) ;       
00045     CCounter & operator --(int) ;       
00046     CCounter & reset() ;                
00047     char *getName() ;                   
00048     operator int () ;                   
00049     ostream&  print(ostream& Out) ;     
00050 } ;
00055 class CListCounters : public List<CCounter> {
00056 } ;
00057 
00061 class CCounterList {
00062 protected:
00063     CListCounters m_Counters ;
00064 public:
00065     CCounterList() ;
00066     virtual ~CCounterList() ;
00067 
00068     CCounterList & operator << (CCounter &Counter) ;
00069     CCounterList & addCounter(char *name) ;         
00070     CCounter & counter(char *name) ;                
00071     CCounter & operator()(char *Name) ;             
00072     ostream&  print(ostream& Out) ;                 
00073     inline CListCounters & getList()                
00074         { return m_Counters; } ; 
00075 } ;
00076 
00077 // out-of-class method to print-out counter values
00078 ostream&  operator<<(ostream& Out, CCounter &P) ;
00079 ostream&  operator<<(ostream& Out, CCounterList &P) ;
00080 
00081 #endif
00082