Changeset 21046

Show
Ignore:
Timestamp:
02/23/08 10:42:23 (9 months ago)
Author:
patrick
Message:

Updated the implementation of the debug output classes to use more modern
C++ techniques and recommendations. There is still more room for improvement,
of course.

Make better use of puncutation and language style in various status messages.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • juggler/trunk/modules/vapor/vpr/Util/Debug.cpp

    r21044 r21046  
    3636#include <vpr/vprConfig.h> 
    3737 
    38 #include <stdlib.h
     38#include <cstdlib
    3939#include <iostream> 
    4040#include <fstream> 
    4141#include <sstream> 
    4242#include <vector> 
     43#include <utility> 
    4344#include <boost/concept_check.hpp> 
    4445 
     
    8182 
    8283Debug::Debug() 
    83    : mFile(NULL) 
     84   : mDebugEnabled(true) 
     85   , mDebugLevel(2) 
     86   , mIndentLevel(0)     // Initialy don't indent 
     87   , mFile(NULL) 
    8488   , mStreamPtr(&std::cout) 
    85 
    86    indentLevel = 0;     // Initialy don't indent 
    87    debugLevel = 2;      // Should actually try to read env variable 
    88    mUseThreadLocal = false;   // Initially set to false 
    89  
     89   , mUseThreadLocal(false) 
     90
    9091   std::string debug_lev; 
    9192   vpr::System::getenv("VPR_DEBUG_NFY_LEVEL", debug_lev); 
     
    9394   if ( ! debug_lev.empty() ) 
    9495   { 
    95       debugLevel = atoi(debug_lev.c_str()); 
    96       std::cout << "VPR_DEBUG_NFY_LEVEL: Set to " << debugLevel << std::endl 
    97                 << std::flush; 
     96      mDebugLevel = std::atoi(debug_lev.c_str()); 
     97      std::cout << "VPR_DEBUG_NFY_LEVEL set to " << mDebugLevel << std::endl; 
    9898   } 
    9999   else 
    100100   { 
    101       std::cout << "VPR_DEBUG_NFY_LEVEL: Not found. " << std::endl 
    102                 << std::flush; 
    103       std::cout << "VPR_DEBUG_NFY_LEVEL: Defaults to " << debugLevel 
    104                 << std::endl << std::flush; 
    105    } 
    106  
    107    std::cout << "--------------------------------------------------------" << std::endl; 
    108    std::cout << "For more or less debug output change VPR_DEBUG_NFY_LEVEL" << std::endl; 
    109    std::cout << "--------------------------------------------------------" << std::endl; 
     101      std::cout << "VPR_DEBUG_NFY_LEVEL not found; defaults to " 
     102                << mDebugLevel << std::endl; 
     103   } 
     104 
     105   std::cout << "---------------------------------------------------------\n" 
     106             << "For more or less debug output, change VPR_DEBUG_NFY_LEVEL\n" 
     107             << "---------------------------------------------------------" 
     108             << std::endl; 
    110109 
    111110   std::string debug_enable; 
     
    114113   if ( ! debug_enable.empty() ) 
    115114   { 
    116       unsigned int debug_enable_val = atoi(debug_enable.c_str()); 
    117       if ( debug_enable_val != 0 ) 
    118       { 
    119          mDebugEnabled = true; 
    120       } 
    121       else 
    122       { 
    123          mDebugEnabled = false; 
    124       } 
    125       std::cout << "VPR_DEBUG_ENABLE: Set to " << mDebugEnabled << std::endl 
    126                 << std::flush; 
     115      const unsigned int debug_enable_val(std::atoi(debug_enable.c_str())); 
     116      mDebugEnabled = debug_enable_val != 0; 
     117      std::cout << "VPR_DEBUG_ENABLE set to " << mDebugEnabled << std::endl; 
    127118   } 
    128119   else 
    129120   { 
    130121      mDebugEnabled = true; 
    131       std::cout << "VPR_DEBUG_ENABLE: Not found. " << std::endl 
    132                 << std::flush; 
    133       std::cout << "VPR_DEBUG_ENABLE: Defaults to " << mDebugEnabled 
    134                 << std::endl << std::flush; 
     122      std::cout << "VPR_DEBUG_ENABLE not found; defaults to " << mDebugEnabled 
     123                << std::endl; 
    135124   } 
    136125 
    137126   // Check to see if there is a default Debug target 
    138    std::string debug_file_ptr; 
    139    vpr::System::getenv("VPR_DEBUG_FILE", debug_file_ptr); 
    140  
    141    if ( ! debug_file_ptr.empty() ) 
    142    { 
    143       std::string debug_file(debug_file_ptr); 
    144       if ("stderr" == debug_file) 
     127   std::string debug_file; 
     128   vpr::System::getenv("VPR_DEBUG_FILE", debug_file); 
     129 
     130   if ( ! debug_file.empty() ) 
     131   { 
     132      if ( "stderr" == debug_file ) 
    145133      { 
    146134         mStreamPtr = &std::cerr; 
    147135      } 
    148       else if ("stdout" != debug_file
     136      else if ( "stdout" != debug_file
    149137      { 
    150138         setOutputFile(debug_file); 
     
    156144      } 
    157145   } 
     146} 
     147 
     148Debug::~Debug() 
     149{ 
     150   /* Do nothing. */ ; 
    158151} 
    159152 
     
    192185 
    193186std::ostream& Debug::getStream(const vpr::DebugCategory& cat, const int level, 
    194                                const bool show_thread_info, 
    195                                const bool use_indent, const int indentChange, 
     187                               const bool showThreadInfo, 
     188                               const bool useIndent, const int indentChange, 
    196189                               const bool lockStream) 
    197190{ 
     
    200193   // Lock the stream 
    201194#ifdef LOCK_DEBUG_STREAM 
    202    if(lockStream
     195   if ( lockStream
    203196   { 
    204197      debugLock().acquire();     // Get the lock 
     
    208201   // this allows us to avoid pointer dereferences until necessary 
    209202   std::ostream& os = *mStreamPtr; 
    210    if(indentChange < 0)                // If decreasing indent 
    211    { 
    212       indentLevel += indentChange; 
    213    } 
    214  
    215    vprASSERT(indentLevel >= 0 && "Decreased indent below 0, look for bad code"); 
     203   if ( indentChange < 0 )                // If decreasing indent 
     204   { 
     205      mIndentLevel += indentChange; 
     206   } 
     207 
     208   vprASSERT(mIndentLevel >= 0 && "Decreased indent below 0, look for bad code"); 
    216209 
    217210   // --- Create stream header --- // 
    218211   // If we have thread local stuff to do 
    219    if(mUseThreadLocal
    220    { 
    221       if((*gVprDebugCurColor).size() == 0
     212   if ( mUseThreadLocal
     213   { 
     214      if( (*gVprDebugCurColor).size() == 0
    222215      { 
    223216         os << clrRESET; 
     
    230223 
    231224   // Autoregister 
    232    if(mCategories.find(cat.mGuid) == mCategories.end()
     225   if ( mCategories.find(cat.mGuid) == mCategories.end()
    233226   { 
    234227      addCategory(cat); 
    235228   } 
    236229 
    237    vprASSERT(mCategories.find(cat.mGuid) != mCategories.end() && "Failed to auto-register"); 
    238  
    239    std::stringstream sstream; 
     230   vprASSERT(mCategories.find(cat.mGuid) != mCategories.end() && 
     231             "Failed to auto-register"); 
     232 
     233   std::ostringstream sstream; 
    240234   sstream << "[" << vpr::Thread::self() << "] " 
    241235           << (*mCategories.find(cat.mGuid)).second.mPrefix; 
     
    244238   // If not, then output space if we are also using indent (assume this means 
    245239   // new line used) 
    246    if(show_thread_info
     240   if ( showThreadInfo
    247241   { 
    248242      os << sstream.str(); 
    249243   } 
    250    else if(use_indent
     244   else if ( useIndent
    251245   { 
    252246      os << std::string(sstream.str().length(), ' '); 
     
    254248 
    255249   // Insert the correct number of tabs into the stream for indenting 
    256    if(use_indent
    257    { 
    258       for(int i=0;i<indentLevel;i++
     250   if ( useIndent
     251   { 
     252      for ( int i = 0; i < mIndentLevel; ++i
    259253      { 
    260254         os << "\t"; 
     
    263257 
    264258   // If we have thread local stuff to do 
    265    if(mUseThreadLocal
     259   if ( mUseThreadLocal
    266260   { 
    267261      const int column_width(3); 
    268262      int column(0); 
    269       if( (*gVprDebugCurColumn).size() > 0
     263      if ( (*gVprDebugCurColumn).size() > 0
    270264      { 
    271265         column = (*gVprDebugCurColumn).back(); 
    272266      } 
    273267 
    274       for ( int i = 0; i < (column * column_width); ++i ) 
     268      for ( int i = 0; i < column * column_width; ++i ) 
    275269      { 
    276270         os << "\t"; 
    277271      } 
    278  
    279    } 
    280  
    281    if(indentChange > 0)             // If increasing indent 
    282    { 
    283       indentLevel += indentChange; 
     272   } 
     273 
     274   if ( indentChange > 0 )             // If increasing indent 
     275   { 
     276      mIndentLevel += indentChange; 
    284277   } 
    285278 
     
    289282void Debug::addCategory(const vpr::DebugCategory& catId) 
    290283{ 
    291    if(getLevel() >= vprDBG_VERB_LVL
    292    { 
    293       std::cout << "\nAdding category named [" << catId.mName 
    294                 << "]  -- prefix: " << catId.mPrefix 
    295                 << " -- guid: " << catId.mGuid 
    296                 << " to debug categories:" << &mCategories 
    297                 << " size: " << mCategories.size() << std::endl; 
    298    } 
    299    mCategories.insert(std::pair<vpr::GUID,CategoryInfo>(catId.mGuid, 
    300                                                         CategoryInfo(catId.mName
    301                                                                      catId.mPrefix, 
    302                                                                      false, 
    303                                                                      false))); 
    304  
    305    if(getLevel() >= vprDBG_HVERB_LVL) 
    306    { 
    307       std::cout << "new size: " << mCategories.size() << std::endl; 
     284   if ( getLevel() >= vprDBG_VERB_LVL
     285   { 
     286      std::cout << "\n[vpr::Debug] Adding category named '" << catId.mName 
     287                << "' (prefix='" << catId.mPrefix <<  "', GUID=" 
     288                << catId.mGuid << ")\n" 
     289                << "             to debug categories: " << &mCategories 
     290                << " (size=" << mCategories.size() << ")" << std::endl; 
     291   } 
     292 
     293   mCategories.insert(std::make_pair(catId.mGuid
     294                                     CategoryInfo(catId.mName, catId.mPrefix, 
     295                                                  false, false))); 
     296 
     297   if ( getLevel() >= vprDBG_HVERB_LVL ) 
     298   { 
     299      std::cout << "             new size=" << mCategories.size() 
     300                << std::endl; 
    308301      debugDump(); 
    309302   } 
     303 
    310304   updateAllowedCategories(); 
    311    if(getLevel() >= vprDBG_HVERB_LVL) 
     305 
     306   if ( getLevel() >= vprDBG_HVERB_LVL ) 
    312307   { 
    313308      debugDump(); 
     
    321316 
    322317   // Make sure category is in the vector 
    323    Debug::category_map_t::iterator cat = mCategories.find(catId.mGuid); 
    324  
    325    if(cat == mCategories.end()
     318   category_map_t::iterator cat = mCategories.find(catId.mGuid); 
     319 
     320   if ( cat == mCategories.end()
    326321   { 
    327322      // Autoregister 
     
    332327   vprASSERT(cat != mCategories.end() && "Auto-register failed");    // ASSERT: We have a valid category 
    333328 
    334    Debug::category_map_t::iterator cat_all = mCategories.find(vprDBG_ALL.mGuid); 
     329   category_map_t::iterator cat_all = mCategories.find(vprDBG_ALL.mGuid); 
    335330   vprASSERT(cat_all != mCategories.end());    // ASSERT: We have a valid category 
    336331 
    337332   // If I specified to listen to all OR 
    338333   // If it has category of ALL 
    339    bool cat_is_all = (catId.mGuid == vprDBG_ALL.mGuid); 
    340    bool allow_all = ((*cat_all).second.mAllowed == true); 
    341  
    342    if(cat_is_all || allow_all
     334   const bool cat_is_all(catId.mGuid == vprDBG_ALL.mGuid); 
     335   const bool allow_all((*cat_all).second.mAllowed == true); 
     336 
     337   if ( cat_is_all || allow_all
    343338   { 
    344339      allow_category = true; 
     
    351346   // Check dis-allowing 
    352347   // - If a category is disallowed, then set it false 
    353    if(allow_category)   // Only worry about it if it is already enabled 
    354    { 
    355       if( (*cat).second.mDisallowed)      // If disallowed 
     348   if ( allow_category )   // Only worry about it if it is already enabled 
     349   { 
     350      if ( (*cat).second.mDisallowed )      // If disallowed 
    356351      { 
    357352         allow_category = false;          // Dis-allow it 
     
    373368   vpr::System::getenv(disallow_var, dbg_disallow_cats); 
    374369 
    375    if(getLevel() >= vprDBG_VERB_LVL
    376    { 
    377       std::cout << "updateAllowedCategories" << std::endl; 
    378       std::cout << "   updateAllowedCat: Trying to find vprDBG_ALL. guid [" 
    379                 << vprDBG_ALL.mGuid << "] " << std::endl; 
     370   if ( getLevel() >= vprDBG_VERB_LVL
     371   { 
     372      std::cout << "[vpr::Debug::updateAllowedCategories()] " 
     373                << "Trying to find vprDBG_ALL (guid=" << vprDBG_ALL.mGuid 
     374                << ")" << std::endl; 
    380375   } 
    381376 
    382377   // Get cat info for vprDBG_ALL 
    383378   // Auto-register vprDBG_ALL if needed 
    384    Debug::category_map_t::iterator cat_all = mCategories.find(vprDBG_ALL.mGuid); 
    385  
    386    if(cat_all == mCategories.end()
     379   category_map_t::iterator cat_all = mCategories.find(vprDBG_ALL.mGuid); 
     380 
     381   if ( cat_all == mCategories.end()
    387382   { 
    388383      addCategory(vprDBG_ALL); 
    389384      cat_all = mCategories.find(vprDBG_ALL.mGuid); 
    390385   } 
    391    vprASSERT(!mCategories.empty() && "Empty category list"); 
    392    vprASSERT((cat_all != mCategories.end()) && "Could not find vprDBG_ALL in category list");    // ASSERT: We have a valid category 
     386 
     387   vprASSERT(! mCategories.empty() && "Empty category list"); 
     388   // ASSERT: We have a valid category 
     389   vprASSERT(cat_all != mCategories.end() && 
     390             "Could not find vprDBG_ALL in category list"); 
    393391 
    394392   // --- Setup allowed categories --- // 
     
    401399     (*cat_all).second.mAllowed = false;       // Disable the showing of all for now 
    402400 
    403       if(getLevel() >= vprDBG_VERB_LVL) 
    404       { 
    405          std::cout << "   vprDEBUG::Found VPR_DEBUG_ALLOW_CATEGORIES: " 
    406                    << "Updating allowed categories. (If blank, then none allowed.)" 
    407                    << std::endl; 
     401      if ( getLevel() >= vprDBG_VERB_LVL ) 
     402      { 
     403         std::cout << "[vpr::Debug] Found VPR_DEBUG_ALLOW_CATEGORIES; " 
     404                   << "updating allowed categories.\n" 
     405                   << "             (If the list is empty, then none are " 
     406                   << "allowed.)" << std::endl; 
    408407      } 
    409408 
    410409      // For each currently known category name 
    411       category_map_t::iterator i
    412       for ( i = mCategories.begin(); i != mCategories.end(); ++i ) 
    413       { 
    414          std::string cat_name = (*i).second.mName; 
    415          if (dbg_allow_cats.find(cat_name) != std::string::npos )    // Found one 
     410      typedef category_map_t::iterator iter_type
     411      for ( iter_type i = mCategories.begin(); i != mCategories.end(); ++i ) 
     412      { 
     413         const std::string& cat_name = (*i).second.mName; 
     414         if ( dbg_allow_cats.find(cat_name) != std::string::npos )    // Found one 
    416415         { 
    417             if(getLevel() >= vprDBG_CONFIG_LVL
     416            if ( getLevel() >= vprDBG_CONFIG_LVL
    418417            { 
    419                std::cout << "   vprDEBUG::updateAllowedCategories: Allowing:
    420                          << (*i).second.mName.c_str() << " val:" 
    421                          << (*i).first.toString() << std::endl; 
     418               std::cout << "[vpr::Debug::updateAllowedCategories()]
     419                         << "Allowing " << (*i).second.mName 
     420                         << " (GUID=" << (*i).first << ")" << std::endl; 
    422421            } 
    423422            (*i).second.mAllowed = true; 
     
    425424         else 
    426425         { 
    427             if(getLevel() >= vprDBG_HVERB_LVL
     426            if ( getLevel() >= vprDBG_HVERB_LVL
    428427            { 
    429               std::cout << "vprDEBUG::updateAllowedCategories: Not found (to allow):
    430                         << (*i).second.mName.c_str() << " val:" 
    431                         << (*i).first.toString() << std::endl; 
     428              std::cout << "[vpr::Debug::updateAllowedCategories()]
     429                        << "Not found (to allow) " << (*i).second.mName 
     430                        << " (GUID=" << (*i).first << ")" << std::endl; 
    432431            } 
    433432         } 
     
    436435   else 
    437436   { 
    438       if(getLevel() >= vprDBG_CONFIG_LVL
    439       { 
    440          std::cout << "   vprDEBUG::VPR_DEBUG_ALLOW_CATEGORIES not found:\n
    441                    << " Setting to: vprDBG_ALL!" << std::endl; 
     437      if ( getLevel() >= vprDBG_CONFIG_LVL
     438      { 
     439         std::cout << "[vpr::Debug] VPR_DEBUG_ALLOW_CATEGORIES not found;
     440                   << "setting to vprDBG_ALL!" << std::endl; 
    442441      } 
    443442      (*cat_all).second.mAllowed = true;       // Enable the showing of all for now 
     
    447446   if ( ! dbg_disallow_cats.empty() ) 
    448447   { 
    449       if(getLevel() >= vprDBG_CONFIG_LVL) 
    450       { 
    451          std::cout << "   vprDEBUG::Found VPR_DEBUG_DISALLOW_CATEGORIES: " 
    452                    << "Updating dis-allowed categories. (If blank, then none dis-allowed.)" 
    453                    << std::endl; 
     448      if ( getLevel() >= vprDBG_CONFIG_LVL ) 
     449      { 
     450         std::cout << "[vpr::Debug] Found VPR_DEBUG_DISALLOW_CATEGORIES; " 
     451                   << "updating disallowed categories.\n" 
     452                   << "             (If the list is empty, then none are " 
     453                   << "disallowed.)" << std::endl; 
    454454      } 
    455455 
    456456      // For each currently known category name 
    457       category_map_t::iterator i
    458       for ( i = mCategories.begin(); i != mCategories.end(); ++i ) 
    459       { 
    460          std::string cat_name = (*i).second.mName; 
    461          if (dbg_disallow_cats.find(cat_name) != std::string::npos )    // Found one 
     457      typedef category_map_t::iterator iter_type
     458      for ( iter_type i = mCategories.begin(); i != mCategories.end(); ++i ) 
     459      { 
     460         const std::string& cat_name = (*i).second.mName; 
     461         if ( dbg_disallow_cats.find(cat_name) != std::string::npos )    // Found one 
    462462         { 
    463             if(getLevel() >= vprDBG_CONFIG_LVL
     463            if ( getLevel() >= vprDBG_CONFIG_LVL
    464464            { 
    465                std::cout << "   vprDEBUG::updateAllowedCategories: Disallowing:
    466                          << (*i).second.mName.c_str() << " val:
    467                          << (*i).first.toString() << std::endl; 
     465               std::cout << "[vpr::Debug::updateAllowedCategories()]
     466                         << "Disallowing " << (*i).second.mName << " (GUID=
     467                         << (*i).first << ")" << std::endl; 
    468468            } 
    469469            (*i).second.mDisallowed = true; 
     
    471471         else 
    472472         { 
    473             if(getLevel() >= vprDBG_VERB_LVL
     473            if ( getLevel() >= vprDBG_VERB_LVL
    474474            { 
    475                std::cout << "vprDEBUG::updateAllowedCategories: Not found (to allow):
    476                          << (*i).second.mName.c_str() << " val:" 
    477                          << (*i).first.toString() << std::endl; 
     475               std::cout << "[vpr::Debug::updateAllowedCategories()]
     476                         << "Not found (to disallow): " << (*i).second.mName 
     477                         << " (GUID=" << (*i).first << ")" << std::endl; 
    478478            } 
    479479         } 
     
    482482   else 
    483483   { 
    484       if(getLevel() >= vprDBG_VERB_LVL
    485       { 
    486          std::cout << "   vprDEBUG::VPR_DEBUG_DISALLOW_CATEGORIES not found.\n
    487                    << std::flush
    488       } 
    489    } 
    490  
    491 } 
    492  
    493 void Debug::pushThreadLocalColumn(int column) 
     484      if ( getLevel() >= vprDBG_VERB_LVL
     485      { 
     486         std::cout << "[vpr::Debug] VPR_DEBUG_DISALLOW_CATEGORIES not found.
     487                   << std::endl
     488      } 
     489   } 
     490 
     491} 
     492 
     493void Debug::pushThreadLocalColumn(const int column) 
    494494{ 
    495495   (*gVprDebugCurColumn).push_back(column); 
     
    498498void Debug::popThreadLocalColumn() 
    499499{ 
    500    if( (*gVprDebugCurColumn).size() > 0
     500   if ( (*gVprDebugCurColumn).size() > 0
    501501   { 
    502502      (*gVprDebugCurColumn).pop_back(); 
     
    511511void Debug::popThreadLocalColor() 
    512512{ 
    513    if( (*gVprDebugCurColor).size() > 0
     513   if ( (*gVprDebugCurColor).size() > 0
    514514   { 
    515515      (*gVprDebugCurColor).pop_back(); 
     
    517517} 
    518518 
    519 void Debug::debugDump() 
     519void Debug::debugDump() const 
    520520{ 
    521521   std::cout << "--- vpr::Debug Status ----" << std::endl; 
    522    Debug::category_map_t::iterator i
    523  
    524    for(i=mCategories.begin(); i != mCategories.end(); ++i
     522   typedef category_map_t::const_iterator iter_type
     523 
     524   for ( iter_type i = mCategories.begin(); i != mCategories.end(); ++i
    525525   { 
    526526      CategoryInfo cat_info = (*i).second; 
    527       std::cout << "    cat [" << (*i).first << "]
    528                 << " name [" << cat_info.mName << "]
    529                 << " prefix [" << cat_info.mPrefix << "]
    530                 << " allowed [" << cat_info.mAllowed << "]
    531                 << " disallowed [" << cat_info.mDisallowed << "] " << std::endl; 
    532    } 
    533  
     527      std::cout << "   cateogry=" << (*i).first << "
     528                << " name='" << cat_info.mName << "'
     529                << " prefix='" << cat_info.mPrefix << "'
     530                << " allowed=" << cat_info.mAllowed << "
     531                << " disallowed=" << cat_info.mDisallowed << " " 
     532                << std::endl; 
     533   } 
    534534} 
    535535 
    536536void Debug::decrementIndentLevel() 
    537537{ 
    538    vprASSERT(indentLevel > 0 && "Attempt to decrrement indent level below 0, check for bad code"); 
    539    indentLevel--; 
     538   vprASSERT(mIndentLevel > 0 && 
     539             "Attempt to decrrement indent level below 0, check for bad code"); 
     540   --mIndentLevel; 
    540541} 
    541542 
    542543void Debug::incrementIndentLevel() 
    543544{ 
    544    indentLevel++; 
     545   ++mIndentLevel; 
     546
     547 
     548Debug::CategoryInfo::CategoryInfo(const std::string& name, 
     549                                  const std::string& prefix, 
     550                                  const bool allowed, const bool disallowed) 
     551   : mName(name) 
     552   , mPrefix(prefix) 
     553   , mAllowed(allowed) 
     554   , mDisallowed(disallowed) 
     555
     556   /* Do nothing. */ ; 
    545557} 
    546558 
     
    556568   , mIndent(indent) 
    557569{ 
    558    if(mIndent
     570   if ( mIndent
    559571   { 
    560572      vprDEBUG_BEGIN(mCat, mLevel) << mEntryText << vprDEBUG_FLUSH; 
     
    568580DebugOutputGuard::~DebugOutputGuard() 
    569581{ 
    570    if(mIndent
     582   if ( mIndent
    571583   { 
    572584      // Don't bother printing anything if mExitText is an empty string. 
    573       if(mExitText == std::string("")
     585      if ( mExitText.empty()
    574586      { 
    575587         vprDEBUG_DECREMENT_INDENT(mCat, mLevel); 
     
    583595   { 
    584596      // Don't bother printing anything if mExitText is an empty string. 
    585       if(mExitText != std::string("")
     597      if ( ! mExitText.empty()
    586598      { 
    587599         vprDEBUG(mCat, mLevel) << mExitText << vprDEBUG_FLUSH; 
  • juggler/trunk/modules/vapor/vpr/Util/Debug.h

    r21044 r21046  
    4242#include <string> 
    4343#include <map> 
     44#include <boost/noncopyable.hpp> 
    4445 
    4546#include <vpr/Sync/Mutex.h> 
     
    5051 
    5152 
    52 // Suggested use of val/debugLevel 
     53// Suggested use of val/ebugLevel 
    5354// 
    5455// 0 - Critical messages (always need to be seen) 
     
    211212    * Class to support debug output. 
    212213    */ 
    213    class VPR_CLASS_API Debug 
     214   class VPR_CLASS_API Debug : private boost::noncopyable 
    214215   { 
    215216   protected: 
     
    220221      Debug(); 
    221222 
    222       // These two have to be here because Visual C++ will try to make them 
    223       // exported public symbols.  This causes problems because copying  
    224       // vpr::Mutex objects is not allowed. 
    225       Debug(const Debug&) {;} 
    226       void operator= (const Debug&) {;} 
    227  
    228223      /** Initialize the system */ 
    229224      void init(); 
     
    231226   public: 
    232227 
    233       ~Debug() 
    234       { 
    235       } 
     228      ~Debug(); 
    236229 
    237230      /** 
     
    257250      /** Gets the debug stream to use */ 
    258251      std::ostream& getStream(const vpr::DebugCategory& cat, const int level, 
    259                               const bool show_thread_info = true, 
    260                               const bool use_indent = true,  
     252                              const bool showThreadInfo = true, 
     253                              const bool useIndent = true,  
    261254                              const int indentChange = 0, 
    262255                              const bool lockStream = true); 
    263256 
    264       int getLevel() 
    265       { 
    266          return debugLevel; 
     257      int getLevel() const 
     258      { 
     259         return mDebugLevel; 
    267260      } 
    268261 
     
    301294       */ 
    302295      //@{ 
    303       void pushThreadLocalColumn(int column); 
     296      void pushThreadLocalColumn(const int column); 
    304297      void popThreadLocalColumn(); 
    305298      void pushThreadLocalColor(const std::string& color); 
     
    310303      //@{ 
    311304      /** Is debugging enabled? */ 
    312       bool isDebugEnabled() 
     305      bool isDebugEnabled() const 
    313306      { 
    314307         return mDebugEnabled; 
     
    329322 
    330323      /** Dumps the current status to screen. */ 
    331       void debugDump()
     324      void debugDump() const
    332325 
    333326      /** Decrements the level of indention. */ 
     
    338331 
    339332   private: 
    340       bool mDebugEnabled;  /**< Is debug output enabled? */ 
    341       int debugLevel;      /**< Debug level to use */ 
    342       int indentLevel;     /**< Amount to indent */ 
     333      bool mDebugEnabled;    /**< Is debug output enabled? */ 
     334      int mDebugLevel;      /**< Debug level to use */ 
     335      int mIndentLevel;     /**< Amount to indent */ 
    343336 
    344337      std::ofstream* mFile;     /**< File we are using for all output. */ 
     
    350343      Mutex mDebugLock; 
    351344 
    352       struct CategoryInfo 
    353       { 
    354          /*CategoryInfo() 
    355           : mName("un-named"), mPrefix("unset"), mAllowed(false) 
    356          {;}*/ 
    357  
     345      struct VPR_CLASS_API CategoryInfo 
     346      { 
    358347         CategoryInfo(const std::string& name, const std::string& prefix, 
    359                       const bool allowed, const bool disallowed) 
    360             : mName(name) 
    361             , mPrefix(prefix) 
    362             , mAllowed(allowed) 
    363             , mDisallowed(disallowed) 
    364          {;} 
     348                      const bool allowed, const bool disallowed); 
    365349 
    366350         std::string mName;         /**< What is the name of the category */