Each library (and the client, if you so choose) may have its own collection of statistics. To enable rapid addition and modifying of the counters kept, a Perl script takes a brief description of the statistics and genenerates a series of files for including in your source code.
Output
The Perl script stats.pl in tools/ takes a file (usually named something like xxx_stats.dat) of the form:
name1 name2 = mask class {
type STATNAME Descriptive string
type STATNAME Descriptive string
...
type STATNAME Descriptive string
}
- "name1" and "name2" are no longer used by the storage manager, but must be present.
- "mask" can be in octal (0777777), hex (0xabcdeff) or decimal notation. It should be unique among statistics modules. It is no longer used by the storage manager but must be present.
- "class" is required. Output file names contain the class name as a prefix.
- "type" must be a one-word type:
- base_stat, unsigned int, unsigned long, unsigned, u_int, u_long, int, long, ulong are synonyms for base_stat_t
- float, base_float, and double are synonyms for base_float_t
- STATNAME is the attribute name of the counter in the C++ class. These attribute names are generated in the output for inclusion in code that declares the class.
- "Descriptive string" will be quoted by the translator. Don't put it in quotes in the .dat file.
Output
for each class this script creates:
- <class>_dec_gen.cpp : definition of <class>& operator -= (<class> &, const <class> &);
- <class>_inc_gen.cpp : definition of <class>& operator += (<class> &, const <class> &);
- <class>_out_gen.cpp : definition of <class>& operator << (ostream &, const <class> &);
- <class>_collect_gen.cpp : contains code used by virtual table code. Not for general use.
- <class>_struct_gen.h : contains list of attribute members for the class:w
- <class>_collect_enum_gen.h : Enumeration values used by virtual table code. Not for general use.
- <class>_msg_gen.h : the descriptive strings.
Use as follows:
class \<class\> {
public:
#include "<class\>_struct_gen.h"
<class>() { ... }
~<class>() { ... }
void clear() {
memset((void *)this, '\0', sizeof(*this));
}
};
#include "\<class\>_inc_gen.cpp"
#include "\<class\>_dec_gen.cpp"
#include "\<class\>_out_gen.cpp"
const char *<class>::stat_names[] = {
#include "\<class\>_msg_gen.h"
}