Main Page | Namespace List | Class Hierarchy | Compound List | File List | Namespace Members | Compound Members | File Members

verbosity.h

Go to the documentation of this file.
00001 /**************************************************************************
00002 ***    
00003 *** Copyright (c) 1995-2000 Regents of the University of California,
00004 ***               Andrew E. Caldwell, Andrew B. Kahng and Igor L. Markov
00005 *** Copyright (c) 2000-2004 Regents of the University of Michigan,
00006 ***               Saurabh N. Adya, Jarrod A. Roy and Igor L. Markov
00007 ***
00008 ***  Contact author(s): abk@cs.ucsd.edu, imarkov@umich.edu
00009 ***  Original Affiliation:   UCLA, Computer Science Department,
00010 ***                          Los Angeles, CA 90095-1596 USA
00011 ***
00012 ***  Permission is hereby granted, free of charge, to any person obtaining 
00013 ***  a copy of this software and associated documentation files (the
00014 ***  "Software"), to deal in the Software without restriction, including
00015 ***  without limitation 
00016 ***  the rights to use, copy, modify, merge, publish, distribute, sublicense, 
00017 ***  and/or sell copies of the Software, and to permit persons to whom the 
00018 ***  Software is furnished to do so, subject to the following conditions:
00019 ***
00020 ***  The above copyright notice and this permission notice shall be included
00021 ***  in all copies or substantial portions of the Software.
00022 ***
00023 *** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 
00024 *** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
00025 *** OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 
00026 *** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
00027 *** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
00028 *** OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
00029 *** THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00030 ***
00031 ***
00032 ***************************************************************************/
00033 
00034 
00035 
00036 
00037 
00038 
00039 
00040 
00042 
00043 #ifndef _VERBOSITY_H_
00044 #define _VERBOSITY_H_
00045 
00046 #include <stdarg.h>
00047 #include <vector>
00048 #include <iostream>
00049 
00050 //: Click to see more comments for verbosity
00051 //   The goal of standardization of verbosity options
00052 //   is to be able to produce consistent diagnostics
00053 //   when using multiple packages. For example, if you
00054 //   run package B with option "silent" and it uses
00055 //   package A, then package A should also understand
00056 //   "silent".
00057 //
00058 //   Use model: constructors of complicated objects
00059 //              can receive optional parameters.
00060 //              A Verbosity object will be one of them
00061 //              (with default "silent").
00062 //              If an object wishes to write some
00063 //              diagnostics, it first looks at
00064 //              the verbosity level for this type
00065 //              of diagnostics and decides whether
00066 //              to write diags or not.
00067 //
00068 //              Note: ATM stderr/cerr output should
00069 //                    not be affected by class Verbosity
00070 //
00071 //   Class Verbosity stores "verbosity levels"
00072 //   for a variable number of "diagnostic types".
00073 //
00074 //   A verbosty level is an unsigned which tells
00075 //   how much diagnostic output of a given type
00076 //   should be printed to cout. Verbosity level
00077 //   0 means "silent" and the bigger the level,
00078 //   the more output should be printed (level
00079 //   K contains all output of level N if K>=N).
00080 //
00081 //   At present, verbosity levels are required for
00082 //   at least three diagnostic types (see comments
00083 //   in the definition of clas Verbosity). Required
00084 //   diag. types have additional support in 
00085 //   class Verbose.
00086 //   Tentative general requirements:  for each type,
00087 //   output with levels < 10^(k+1) should
00088 //   be O(n^k) -  long (wrt the program input).
00089 //
00090 //   Usage: this class can be used as is or as a base class.
00091 //
00092 //   Note: if needed, we can add extensions to handle
00093 //   output to different diagnostic streams
00094 //   (e.g. for each type)
00095 class Verbosity 
00096 {
00097    std::vector<unsigned>  _levels;
00098 
00099    void _ctructFromString(const char* levels);
00100 
00101  public:
00102 
00103     Verbosity(); 
00104     // the default is "silent"
00105     Verbosity(const char* levels);
00106     //  space or underscore-separated unsigneds 
00107     //  can also be "silent" and "0" (same as "0 0 0", same as "0_0_0")
00108     Verbosity(int argc, const char *argv[]); 
00109     //  catches -verb 
00110     Verbosity(unsigned numArgs, unsigned forActions, 
00111               unsigned forSysRes, unsigned forMajStats, ...);
00112     Verbosity(const std::vector<unsigned>&);
00113 
00114     Verbosity(const Verbosity& v):_levels(v._levels),
00115       forActions(_levels[0]),forSysRes(_levels[1]),forMajStats(_levels[2]) {}
00116   
00117     Verbosity& operator=(const Verbosity&);
00118 
00119     unsigned getNumTypes() const { return _levels.size(); }
00120 
00121     unsigned& operator[](unsigned diagType);
00122 
00123   
00124     unsigned & forActions;
00125     // "verbosity for actions" means writing "doing this, doing that"
00126     //    with more or less detail, depending on the level
00127 
00128     unsigned & forSysRes;
00129     // "verbosity for system resources" means writing
00130     //    how much memory/CPU time/etc was used
00131     //    in more or fewer places depending on the level
00132 
00133     unsigned & forMajStats;
00134     // "verbosity for major stats" means writing
00135     //    quantities/sizes of importants components,
00136     //    on more or fewer occasions, depending on the level
00137 
00138     friend std::ostream& operator<<(std::ostream& os, const Verbosity& verbsty);
00139 
00140 };
00141 
00142 std::ostream& operator<<(std::ostream& os, const Verbosity& verbsty);
00143 
00144 #endif

Generated on Mon Apr 25 01:09:25 2005 for Parquete by doxygen 1.3.2