ESyS-Particle  2.3.4
Counter.h
Go to the documentation of this file.
1 // //
3 // Copyright (c) 2003-2017 by The University of Queensland //
4 // Centre for Geoscience Computing //
5 // http://earth.uq.edu.au/centre-geoscience-computing //
6 // //
7 // Primary Business: Brisbane, Queensland, Australia //
8 // Licensed under the Open Software License version 3.0 //
9 // http://www.apache.org/licenses/LICENSE-2.0 //
10 // //
12 
13 #ifndef _COUNTER_H_
14 #define _COUNTER_H_
15 #include "t_list.h"
16 
17 //--- IO includes ---
18 #include <iostream>
19 #include <cstdio>
20 using std::ostream;
21 
22 //--- system includes ---
23 #include <string.h>
24 
29 class CCounter {
30 protected:
31  char *Name ;
32  int Value ;
33  int Id ;
34 public:
35  CCounter() ;
36  CCounter(char *Name, int Id=0) ;
37  virtual ~CCounter() ;
38 
39  void create(char *Name, int Id=0) ;
40  CCounter & operator +=(int n) ;
41  CCounter & operator -=(int n) ;
42  CCounter & operator ++() ;
43  CCounter & operator --() ;
44  CCounter & operator ++(int) ;
45  CCounter & operator --(int) ;
46  CCounter & reset() ;
47  char *getName() ;
48  operator int () ;
49  ostream& print(ostream& Out) ;
50 } ;
55 class CListCounters : public List<CCounter> {
56 } ;
57 
61 class CCounterList {
62 protected:
64 public:
65  CCounterList() ;
66  virtual ~CCounterList() ;
67 
68  CCounterList & operator << (CCounter &Counter) ;
69  CCounterList & addCounter(char *name) ;
70  CCounter & counter(char *name) ;
71  CCounter & operator()(char *Name) ;
72  ostream& print(ostream& Out) ;
73  inline CListCounters & getList()
74  { return m_Counters; } ;
75 } ;
76 
77 // out-of-class method to print-out counter values
78 ostream& operator<<(ostream& Out, CCounter &P) ;
79 ostream& operator<<(ostream& Out, CCounterList &P) ;
80 
81 #endif
82 
CCounterList::~CCounterList
virtual ~CCounterList()
Definition: Counter.cpp:76
List::IsEnd
int IsEnd()
Definition: t_list.hpp:261
CCounterList::addCounter
CCounterList & addCounter(char *name)
add a counter of name "name"
Definition: Counter.cpp:103
CCounter::Name
char * Name
Name is allocated or deallocated on construction or destruction, respectively.
Definition: Counter.h:31
List::Get
T * Get()
Definition: t_list.hpp:161
operator<<
ostream & operator<<(ostream &Out, CCounter &P)
Definition: Counter.cpp:128
CCounter::create
void create(char *Name, int Id=0)
create counter, call by constructor
Definition: Counter.cpp:29
CCounter::~CCounter
virtual ~CCounter()
Definition: Counter.cpp:25
CCounter::Value
int Value
Definition: Counter.h:32
CCounterList::print
ostream & print(ostream &Out)
method to print out all counters
Definition: Counter.cpp:113
CListCounters
Definition: Counter.h:55
Console::Error
Console & Error()
set verbose level of next message to "err"
CCounter::print
ostream & print(ostream &Out)
method to print the value
Definition: Counter.cpp:123
console.h
CCounter::operator+=
CCounter & operator+=(int n)
increment counter by n
Definition: Counter.cpp:36
List::First
void First()
Definition: t_list.hpp:249
CCounterList
Definition: Counter.h:61
CCounterList::CCounterList
CCounterList()
Definition: Counter.cpp:73
List::Next
void Next()
Definition: t_list.hpp:237
CCounterList::getList
CListCounters & getList()
Definition: Counter.h:73
CCounter::reset
CCounter & reset()
reset the counter to 0
Definition: Counter.cpp:60
CCounter::CCounter
CCounter()
Definition: Counter.cpp:17
t_list.h
NULL
#define NULL
Definition: t_list.h:17
List::Append
void Append(T *V)
Definition: t_list.hpp:95
List::Clear
void Clear()
Definition: t_list.hpp:181
CCounter::Id
int Id
Definition: Counter.h:33
CCounterList::m_Counters
CListCounters m_Counters
Definition: Counter.h:63
CCounter::operator++
CCounter & operator++()
increment counter by 1
Definition: Counter.cpp:44
Counter.h
CCounterList::counter
CCounter & counter(char *name)
return the counter "name"
Definition: Counter.cpp:90
List
Definition: t_list.h:41
console
Console console
Definition: console.cpp:25
CCounterList::operator()
CCounter & operator()(char *Name)
return the counter "name"
Definition: Counter.cpp:109
CCounter::getName
char * getName()
return name of counter
Definition: Counter.cpp:65
operator<<
ostream & operator<<(ostream &Out, CCounter &P)
Definition: Counter.cpp:128
CCounter
Definition: Counter.h:29
CCounter::operator--
CCounter & operator--()
decrement counter by 1
Definition: Counter.cpp:48
CCounter::operator-=
CCounter & operator-=(int n)
decrement counter by n
Definition: Counter.cpp:40
CCounterList::operator<<
CCounterList & operator<<(CCounter &Counter)
add a counter "Counter"
Definition: Counter.cpp:84