w_stat.h

00001 /*<std-header orig-src='shore' incl-file-exclusion='W_STAT_H'>
00002 
00003  $Id: w_stat.h,v 1.1 2010/05/26 01:20:26 nhall Exp $
00004 
00005 SHORE -- Scalable Heterogeneous Object REpository
00006 
00007 Copyright (c) 1994-99 Computer Sciences Department, University of
00008                       Wisconsin -- Madison
00009 All Rights Reserved.
00010 
00011 Permission to use, copy, modify and distribute this software and its
00012 documentation is hereby granted, provided that both the copyright
00013 notice and this permission notice appear in all copies of the
00014 software, derivative works or modified versions, and any portions
00015 thereof, and that both notices appear in supporting documentation.
00016 
00017 THE AUTHORS AND THE COMPUTER SCIENCES DEPARTMENT OF THE UNIVERSITY
00018 OF WISCONSIN - MADISON ALLOW FREE USE OF THIS SOFTWARE IN ITS
00019 "AS IS" CONDITION, AND THEY DISCLAIM ANY LIABILITY OF ANY KIND
00020 FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
00021 
00022 This software was developed with support by the Advanced Research
00023 Project Agency, ARPA order number 018 (formerly 8230), monitored by
00024 the U.S. Army Research Laboratory under contract DAAB07-91-C-Q518.
00025 Further funding for this work was provided by DARPA through
00026 Rome Research Laboratory Contract No. F30602-97-2-0247.
00027 
00028 */
00029 
00030 #ifndef W_STAT_H
00031 #define W_STAT_H
00032 
00033 #include "w_defines.h"
00034 
00035 /*  -- do not edit anything above this line --   </std-header>*/
00036 
00037 #ifdef __GNUG__
00038 #pragma interface
00039 #endif
00040 
00041 #ifndef W_BASE_H
00042 #include <w_base.h>
00043 #endif
00044 #ifndef W_RC_H
00045 #include <w_rc.h>
00046 #endif
00047 
00048 class w_statistics_t; // forward
00049 class w_stat_module_t; // forward
00050 
00051 /**\page STATS Sets of Statistics
00052  * Each library (and the client, if you so choose) may have
00053  * its own collection of statistics. To enable rapid addition and
00054  * modifying of the counters kept, a Perl script takes a brief
00055  * description of the statistics and genenerates a series of files
00056  * for including in your source code.
00057  *
00058  * \section STATSOUT Output
00059  * The Perl script stats.pl in tools/ takes a file  (usually
00060  * named something like xxx_stats.dat) of the form:
00061  * \code
00062  * name1 name2 = mask class {
00063  *    type STATNAME    Descriptive string
00064  *    type STATNAME    Descriptive string
00065  *     ...
00066  *    type STATNAME    Descriptive string
00067  *    }
00068  * \endcode
00069  *
00070  * - "name1" and "name2" are no longer used by the
00071  *         storage manager, but must be present.
00072  *
00073  * - "mask" can be in octal (0777777), hex (0xabcdeff) or decimal 
00074  *         notation. It should be unique among statistics modules.
00075  *         It is no longer used by the storage manager but must be present.
00076  *
00077  * - "class" is required. Output file names contain the class name as a prefix.
00078  *
00079  * - "type" must be a one-word type:
00080  *        - base_stat, unsigned int, unsigned long, unsigned,
00081  *          u_int, u_long, int, long, ulong are synonyms for base_stat_t 
00082  *        - float, base_float, and double are synonyms for base_float_t
00083  *
00084  * - STATNAME is the attribute name of the counter in the C++ class.
00085  *        These attribute names are generated in the output for inclusion
00086  *        in code that declares the class.
00087  *
00088  * - "Descriptive string" will be quoted by the translator.  Don't
00089  *        put it in quotes in the .dat file.
00090  *
00091  * \section STATSOUT Output
00092  *  for each class  this script creates:
00093  
00094  *  - <class>_dec_gen.cpp : definition of 
00095  *         <class>& operator -= (<class> &, const <class> &);
00096  *  - <class>_inc_gen.cpp : definition of 
00097  *         <class>& operator += (<class> &, const <class> &);
00098  *  - <class>_out_gen.cpp : definition of 
00099  *         <class>& operator << (ostream &, const <class> &);
00100  *  - <class>_collect_gen.cpp : contains code used by virtual table
00101  *                    code. Not for general use.
00102  *  - <class>_struct_gen.h : contains list of attribute members for the class:w
00103  *  - <class>_collect_enum_gen.h :  Enumeration values used by virtual
00104  *                    table code. Not for general use.
00105  *  - <class>_msg_gen.h : the descriptive strings. 
00106  *
00107  *  Use as follows:
00108  *  \code
00109  *  class <class> {
00110  *  public:
00111  *  #include "<class>_struct_gen.h"
00112  *      <class>() { ... }
00113  *      ~<class>() { ... }
00114  *      void clear() {
00115  *          memset((void *)this, '\0', sizeof(*this));
00116  *      }
00117  *  };
00118  *
00119  *  #include "<class>_inc_gen.cpp"
00120  *  #include "<class>_dec_gen.cpp"
00121  *  #include "<class>_out_gen.cpp"
00122  *
00123  *  const char *<class>::stat_names[] = {
00124  *  #include "<class>_msg_gen.h"
00125  *  }
00126  *
00127  *  \endcode
00128  */
00129 
00130 /**\brief A single statistic punning structure. 
00131  *
00132  * This structure holds a single generic statistic, be it an integer or
00133  * a floating-point number.  These are the statistics that are described
00134  * in inputs to a Perl script, and whose handling-code is generated by that script.
00135  * See \ref STATS.
00136  *
00137  * This struct doesn't do much; it's a union of the two numeric types
00138  * w_base_t::base_stat_t and w_base_t::base_float_t.
00139  * With this class you output the contents to an output stream,  and
00140  * compare two stats (equal, not-equal).
00141  */
00142 class w_stat_t 
00143 {
00144     friend class w_statistics_t;
00145     friend class w_stat_module_t;
00146     /* grot */
00147     friend ostream    & operator<<(ostream &out, const w_statistics_t &s);
00148 
00149 protected:
00150     union {
00151         w_base_t::base_stat_t   i;
00152         w_base_t::base_float_t  f;
00153     }_u;
00154 
00155 public:
00156     /// Initialize to zero.
00157     w_stat_t() { _u.i=0; }
00158 
00159     /// Initialize to integer i.
00160     w_stat_t(int  i) { _u.i=i; }
00161     operator int() const { return _u.i; }
00162 
00163     /// Initialize to floating point i.
00164     w_stat_t(w_base_t::base_float_t i) { _u.f=i; }
00165 
00166     /// Interpret as a floating point.
00167     operator w_base_t::base_float_t() const { return _u.f; }
00168 
00169     friend bool    operator==(const w_stat_t &, const w_stat_t &);
00170     friend bool    operator!=(const w_stat_t &, const w_stat_t &);
00171 
00172 };
00173 
00174 /*<std-footer incl-file-exclusion='W_STAT_H'>  -- do not edit anything below this line -- */
00175 
00176 #endif          /*</std-footer>*/

Generated on Wed Jul 7 17:22:32 2010 for Shore Storage Manager by  doxygen 1.4.7