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

Verbosity Class Reference

author="Igor Markov, Nov 16, 1997" More...

#include <verbosity.h>

Collaboration diagram for Verbosity:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 Verbosity ()
 Verbosity (const char *levels)
 Verbosity (int argc, const char *argv[])
 Verbosity (unsigned numArgs, unsigned forActions, unsigned forSysRes, unsigned forMajStats,...)
 Verbosity (const std::vector< unsigned > &)
 Verbosity (const Verbosity &v)
Verbosityoperator= (const Verbosity &)
unsigned getNumTypes () const
unsigned & operator[] (unsigned diagType)

Public Attributes

unsigned & forActions
unsigned & forSysRes
unsigned & forMajStats

Private Member Functions

void _ctructFromString (const char *levels)

Private Attributes

std::vector< unsigned > _levels

Friends

std::ostream & operator<< (std::ostream &os, const Verbosity &verbsty)

Detailed Description

author="Igor Markov, Nov 16, 1997"

Definition at line 95 of file verbosity.h.


Constructor & Destructor Documentation

Verbosity::Verbosity  ) 
 

Definition at line 160 of file verbosity.cxx.

00160                     :
00161 _levels(3,1),
00162 forActions(_levels[0]),forSysRes(_levels[1]),forMajStats(_levels[2])
00163 {
00164 }

Verbosity::Verbosity const char *  levels  ) 
 

Definition at line 129 of file verbosity.cxx.

00131 :_levels(100,0),
00132 forActions(_levels[0]),forSysRes(_levels[1]),forMajStats(_levels[2])
00133 {
00134   _ctructFromString(levels);
00135 }

Verbosity::Verbosity int  argc,
const char *  argv[]
 

Definition at line 137 of file verbosity.cxx.

00138 :_levels(100,0),
00139 forActions(_levels[0]),forSysRes(_levels[1]),forMajStats(_levels[2])
00140 {
00141     StringParam verb("verb",argc,argv);
00142     BoolParam helpRequest1("h",argc,argv);
00143     BoolParam helpRequest2("help",argc,argv);
00144 
00145     if (helpRequest1.found() || helpRequest2.found())
00146     {
00147       cout << " -verb 1_1_1 | silent " << endl; 
00148       _levels.erase(_levels.begin()+3,_levels.end());
00149       return;
00150     }
00151   
00152     if (verb.found())  _ctructFromString(verb);
00153     else 
00154     { 
00155        _levels.erase(_levels.begin()+3,_levels.end());
00156        _levels[0]=_levels[1]=_levels[2]=1;
00157     }
00158 }

Verbosity::Verbosity unsigned  numArgs,
unsigned  forActions,
unsigned  forSysRes,
unsigned  forMajStats,
... 
 

Definition at line 175 of file verbosity.cxx.

00176                                                                    :
00177 _levels(numLevels,0),
00178 forActions(_levels[0]),forSysRes(_levels[1]),forMajStats(_levels[2])
00179 {
00180    abkfatal(numLevels>=3,"Can not initialize verbosity --- too few levels\n ");
00181    _levels[0]=ForActions;
00182    _levels[1]=ForSysRes;
00183    _levels[2]=ForMajStats;
00184 
00185    va_list ap;
00186    va_start(ap,ForMajStats);
00187 
00188    for(unsigned k=3;k<numLevels;k++)
00189    {
00190      _levels[k]=va_arg(ap,unsigned);
00191      abkfatal(_levels[k]<INT_MAX/2," Verbosity levels can't be > INT_MAX /2");
00192    }
00193 }

Verbosity::Verbosity const std::vector< unsigned > &   ) 
 

Definition at line 166 of file verbosity.cxx.

00166                                                      :
00167 _levels(levels),
00168 forActions(_levels[0]),forSysRes(_levels[1]),forMajStats(_levels[2])
00169 {
00170    abkfatal(levels.size()>=3,
00171             "Can not initialize verbosity --- too few levels\n ");
00172 }

Verbosity::Verbosity const Verbosity v  )  [inline]
 

Definition at line 114 of file verbosity.h.

References _levels, forActions, forMajStats, and forSysRes.

00114                                  :_levels(v._levels),
00115       forActions(_levels[0]),forSysRes(_levels[1]),forMajStats(_levels[2]) {}


Member Function Documentation

void Verbosity::_ctructFromString const char *  levels  )  [private]
 

Definition at line 93 of file verbosity.cxx.

References _levels, and abkfatal.

00094 {
00095    if (levels==NULL || 
00096        !strcmp(levels,"0") || !strcasecmp(levels,"silent"))
00097    {
00098       _levels.erase(_levels.begin()+3,_levels.end());
00099       return;
00100    }
00101 
00102    unsigned len=strlen(levels);
00103    char * levs=new char[len+1];
00104    for(unsigned c=0;c<len;c++) 
00105    if (levels[c]=='_') levs[c]=' '; else levs[c]=levels[c];
00106    levs[len]='\0';
00107 
00108    unsigned  numLev=0;
00109    char *start =levs;
00110    char *finish=levs;
00111    while (start<levs+len)
00112    {
00113       unsigned tmp=strtoul(start,&finish,10);
00114       if (start==finish) start++;
00115       else 
00116       { 
00117          abkfatal(tmp<=INT_MAX,"Verbosity levels can't be >INT_MAX");
00118          abkfatal(numLev<100,"This ctor can't work with 100+ verbosity levels");
00119          _levels[numLev]=tmp;
00120          start=finish;
00121          numLev++;
00122       }
00123    }
00124    abkfatal(numLev>2," Can't ctruct Verbosity: need at least 3 levels\n ");
00125    _levels.erase(_levels.begin()+numLev,_levels.end());
00126    delete[] levs;
00127 }

unsigned Verbosity::getNumTypes  )  const [inline]
 

Definition at line 119 of file verbosity.h.

References _levels.

Referenced by operator=().

00119 { return _levels.size(); }

Verbosity & Verbosity::operator= const Verbosity  ) 
 

Definition at line 55 of file verbosity.cxx.

References _levels, abkwarn, and getNumTypes().

00056       {
00057          abkwarn(v.getNumTypes()<=_levels.size(),
00058                  "  Losing debug levels while assigning Verbosities\n  Use copy-construction");
00059          for(unsigned k=0;k<v.getNumTypes();k++)
00060              _levels[k]=v._levels[k];
00061          _levels.erase(_levels.begin()+v.getNumTypes(),
00062                        _levels.begin()+getNumTypes());
00063          return *this;
00064       }

Here is the call graph for this function:

unsigned & Verbosity::operator[] unsigned  diagType  ) 
 

Definition at line 195 of file verbosity.cxx.

00196 { 
00197    abkfatal(diagType<_levels.size(),"Inexistant diagnostic type");
00198    return _levels[diagType];
00199 }


Friends And Related Function Documentation

std::ostream& operator<< std::ostream &  os,
const Verbosity verbsty
[friend]
 

Definition at line 66 of file verbosity.cxx.

00067 {
00068         unsigned numLevels=verbsty._levels.size(); 
00069 
00070         os << " Verbosity levels : " << numLevels << endl;
00071         os << " For actions : " << verbsty.forActions << ",  "
00072            << " For sys resources : " << verbsty.forSysRes << ",  "
00073            << " For major stats : " << verbsty.forMajStats << endl;
00074       
00075         if (numLevels > 3)
00076         {
00077           os << " Other levels : " ;
00078           for (unsigned i=3; i!=numLevels; ++i)
00079           {
00080                 if ( i % 10 == 0 )
00081                 {
00082                     if (i) os << endl;
00083                     os <<"      ";
00084                 }
00085                 os<<setw(3)<<verbsty._levels[i]<<" ";
00086           }
00087           os << endl;
00088         }
00089 
00090     return os;
00091 }


Member Data Documentation

std::vector<unsigned> Verbosity::_levels [private]
 

Definition at line 97 of file verbosity.h.

Referenced by _ctructFromString(), getNumTypes(), operator<<(), operator=(), and Verbosity().

unsigned& Verbosity::forActions
 

Definition at line 124 of file verbosity.h.

Referenced by parquetfp::Annealer::anneal(), operator<<(), and Verbosity().

unsigned& Verbosity::forMajStats
 

Definition at line 133 of file verbosity.h.

Referenced by parquetfp::Annealer::anneal(), BaseAnnealer::BaseAnnealer(), parquetfp::ClusterDB::clusterMulti(), parquetfp::Annealer::compactSoln(), parquetfp::SolveMulti::go(), operator<<(), parquetfp::SolveMulti::placeSubBlocks(), BaseAnnealer::printResults(), and Verbosity().

unsigned& Verbosity::forSysRes
 

Definition at line 128 of file verbosity.h.

Referenced by parquetfp::SolveMulti::go(), operator<<(), BaseAnnealer::printResults(), and Verbosity().


The documentation for this class was generated from the following files:
Generated on Mon Apr 25 01:16:12 2005 for Parquete by doxygen 1.3.2