Nemo  2.3.46
StatRecorder< S > Class Template Reference

Stores the pointers to the StatHandler's stat functions. More...

#include <statrecorder.h>

+ Inheritance diagram for StatRecorder< S >:
+ Collaboration diagram for StatRecorder< S >:

Public Member Functions

 StatRecorder ()
 
void set (std::string T, std::string N, age_t AGE, unsigned int ARG1, unsigned int ARG2, double(S::*getNoArg)(void), double(S::*getOneArg)(unsigned int), double(S::*getTwoArg)(unsigned int, unsigned int), void(S::*setStat)(void))
 Sets the recorder attributes. More...
 
void setHandler (S *theHandler)
 Sets the pointer to the StatHandler that owns this recorder. More...
 
virtual double setVal (age_t AGE)
 Calls the linked stat function and returns the result. More...
 
- Public Member Functions inherited from StatRecBase
 StatRecBase ()
 
virtual ~StatRecBase ()
 
void set (std::string T, std::string N, age_t AGE, unsigned int ARG1, unsigned int ARG2)
 Sets the recorder attributes. More...
 
void setName (std::string N)
 
std::string getTitle ()
 
std::string getName ()
 
age_t getAge ()
 
unsigned int getArg1 ()
 
unsigned int getArg2 ()
 

Private Attributes

double(S::* _getStat )(void)
 Pointer to a 'stat getter' function of S using no argument. More...
 
double(S::* _getStatOneArg )(unsigned int)
 Pointer to a 'stat getter' function of S using a single unsigned int argument. More...
 
double(S::* _getStatTwoArg )(unsigned int, unsigned int)
 Pointer to a 'stat getter' function of S using two unsigned int arguments. More...
 
void(S::* _setStat )(void)
 Pointer to a 'stat setter' function of S using no argument. More...
 
S * _myHandler
 Pointer to the owner of this recorder. More...
 

Detailed Description

template<class S>
class StatRecorder< S >

Stores the pointers to the StatHandler's stat functions.

Constructor & Destructor Documentation

template<class S>
StatRecorder< S >::StatRecorder ( )
inline
111  _setStat(0), _myHandler(0) {}
void(S::* _setStat)(void)
Pointer to a 'stat setter' function of S using no argument.
Definition: statrecorder.h:104
S * _myHandler
Pointer to the owner of this recorder.
Definition: statrecorder.h:106
double(S::* _getStatTwoArg)(unsigned int, unsigned int)
Pointer to a 'stat getter' function of S using two unsigned int arguments.
Definition: statrecorder.h:100
double(S::* _getStat)(void)
Pointer to a 'stat getter' function of S using no argument.
Definition: statrecorder.h:96
double(S::* _getStatOneArg)(unsigned int)
Pointer to a 'stat getter' function of S using a single unsigned int argument.
Definition: statrecorder.h:98

Member Function Documentation

template<class S >
void StatRecorder< S >::set ( std::string  T,
std::string  N,
age_t  AGE,
unsigned int  ARG1,
unsigned int  ARG2,
double(S::*)(void)  getNoArg,
double(S::*)(unsigned int getOneArg,
double(S::*)(unsigned int, unsigned int getTwoArg,
void(S::*)(void)  setStat 
)

Sets the recorder attributes.

Parameters
Tthe stat title
Nthe stat name (headers in the output file)
AGEage on which the stat should be processed
ARG1the frist argument to pass to the S function
ARG2the second argument to pass to the S function
getNoArgfunction ptr to a S getter, taking no arguments
getOneArgfunction ptr to a S getter with a single uint argument
getTwoArgfunction ptr to a S getter with two uint arguments
setStatptr to a setter function in class S

References StatRecBase::set().

Referenced by StatHandler< LCE_SelectionSH >::add().

152 {
153  StatRecBase::set(T, N, AGE, ARG1, ARG2);
154 
155  _getStat = getNoArg;
156  _getStatOneArg = getOneArg;
157  _getStatTwoArg = getTwoArg;
158  _setStat = setStat;
159 }
void(S::* _setStat)(void)
Pointer to a 'stat setter' function of S using no argument.
Definition: statrecorder.h:104
double(S::* _getStatTwoArg)(unsigned int, unsigned int)
Pointer to a 'stat getter' function of S using two unsigned int arguments.
Definition: statrecorder.h:100
double(S::* _getStat)(void)
Pointer to a 'stat getter' function of S using no argument.
Definition: statrecorder.h:96
void set(std::string T, std::string N, age_t AGE, unsigned int ARG1, unsigned int ARG2)
Sets the recorder attributes.
Definition: statrecorder.h:65
double(S::* _getStatOneArg)(unsigned int)
Pointer to a 'stat getter' function of S using a single unsigned int argument.
Definition: statrecorder.h:98
template<class S>
void StatRecorder< S >::setHandler ( S *  theHandler)
inline

Sets the pointer to the StatHandler that owns this recorder.

Referenced by StatHandler< LCE_SelectionSH >::add().

129 {_myHandler = theHandler;}
S * _myHandler
Pointer to the owner of this recorder.
Definition: statrecorder.h:106
template<class S >
double StatRecorder< S >::setVal ( age_t  AGE)
virtual

Calls the linked stat function and returns the result.

Returns
the stat value that will be recorded in the output file
Parameters
AGEage class on which the stat should be processed

Implements StatRecBase.

References fatal(), and message().

164 {
165  double statValue = 0;
166 
167  if(getAge() & AGE) {
168 #ifdef _DEBUG_
169  message(" %s",getName().c_str());
170 #endif
171  //run _setStat if exists
172  if(_setStat != 0) (_myHandler->*_setStat)();
173 
174  //get the value:
175  if(_getStat != 0)
176 
177  statValue = (_myHandler->*_getStat)();
178 
179  else if(_getStatOneArg != 0)
180 
181  statValue = (_myHandler->*_getStatOneArg)(getArg1());
182 
183  else if(_getStatTwoArg != 0)
184 
185  statValue = (_myHandler->*_getStatTwoArg)(getArg1(), getArg2());
186 
187  else {
188 
189  fatal("StatRecorder \"%s\" has no _getStat funct ptr !!\n", getName().c_str());
190 
191  }
192  }
193 
194  return statValue;
195 }
void message(const char *message,...)
Definition: output.cc:40
void(S::* _setStat)(void)
Pointer to a 'stat setter' function of S using no argument.
Definition: statrecorder.h:104
std::string getName()
Definition: statrecorder.h:79
void fatal(const char *str,...)
Definition: output.cc:90
S * _myHandler
Pointer to the owner of this recorder.
Definition: statrecorder.h:106
double(S::* _getStatTwoArg)(unsigned int, unsigned int)
Pointer to a 'stat getter' function of S using two unsigned int arguments.
Definition: statrecorder.h:100
unsigned int getArg1()
Definition: statrecorder.h:81
double(S::* _getStat)(void)
Pointer to a 'stat getter' function of S using no argument.
Definition: statrecorder.h:96
double(S::* _getStatOneArg)(unsigned int)
Pointer to a 'stat getter' function of S using a single unsigned int argument.
Definition: statrecorder.h:98
age_t getAge()
Definition: statrecorder.h:80
unsigned int getArg2()
Definition: statrecorder.h:82

Member Data Documentation

template<class S>
double(S::* StatRecorder< S >::_getStat)(void)
private

Pointer to a 'stat getter' function of S using no argument.

template<class S>
double(S::* StatRecorder< S >::_getStatOneArg)(unsigned int)
private

Pointer to a 'stat getter' function of S using a single unsigned int argument.

template<class S>
double(S::* StatRecorder< S >::_getStatTwoArg)(unsigned int, unsigned int)
private

Pointer to a 'stat getter' function of S using two unsigned int arguments.

template<class S>
S* StatRecorder< S >::_myHandler
private

Pointer to the owner of this recorder.

template<class S>
void(S::* StatRecorder< S >::_setStat)(void)
private

Pointer to a 'stat setter' function of S using no argument.

A setter function only sets some inner variables subsequently fetched by getter's


The documentation for this class was generated from the following file:

Generated for Nemo v2.3.0 by  doxygen 1.8.8 --
Catalogued on GSR