//////////////////////////////////////////////////////////////////////////////
//
// File: debug.cc
//
// Purpose: Implementation for Debugging class.
//
// Authors:
//   txe  Travis Emmitt
//
// Modifications:
//   17-APR-1998  txe  Initial creation
//   18-APR-1998  txe  Added GetName(), Peek()
//   19-APR-1998  txe  Added Debugging (name, debug) constructor, destructor
//   20-APR-1998  txe  Purifying...
//   23-APR-1998  txe  Using static debug, changed constructor
//
//////////////////////////////////////////////////////////////////////////////

#include <iostream.h>
#include <stdio.h>
#include "common.h"
#include "debug.h"

////////////////////////////////////////////////////////////////////////////

Debug::Debug () {
  peek_watch = 0;
  SetName ("new object");
}

////////////////////////////////////////////////////////////////////////////

Debug::Debug (char *name) {
  ASSERT (name != NULL);
  this->peek_watch = 0;
  SetName (name);
  DEBUG(NEW) << name << " created\n";
}

////////////////////////////////////////////////////////////////////////////

Debug::~Debug () {
  DEBUG(DEL) << name << " deleted\n";
}

////////////////////////////////////////////////////////////////////////////

char *Debug::GetName () {
  return name;
}

////////////////////////////////////////////////////////////////////////////

void Debug::Peek () {
  cout << "\nPEEK: Nothing to see inside of " << name << "\n";
  peek_watch = 1;
}

////////////////////////////////////////////////////////////////////////////

void Debug::Print () {
  cout << "[" << name << "]\n";
}

////////////////////////////////////////////////////////////////////////////

void Debug::Print (int level) {
  if (debug >= level) {
    Print();
  }
}

////////////////////////////////////////////////////////////////////////////

void Debug::SetName () {
  SetName ("unnamed");
}

////////////////////////////////////////////////////////////////////////////

void Debug::SetName (char *name) {
  ASSERT (name != NULL);
  sprintf (this->name, "%.*s", NAME_LEN, name);
}

////////////////////////////////////////////////////////////////////////////

