#include <iostream>
#include <sstream>

#include "Printer.h"

using namespace std;

Printer::Printer() {
  id_ = Printer::nextid_++;
  value_ = id_;
  cout << "Printer" << PrintID() << endl;
}

Printer::~Printer() {
  cout << "~Printer" << PrintID() << endl;
}

Printer::Printer(const Printer &rhs) {
  id_ = Printer::nextid_++;
  value_ = id_;
  cout << "PrinterCopy[" << PrintID();
  cout << "<--" << rhs.PrintID() << "]" << endl;
  value_ = rhs.value_;
}

Printer &Printer::operator=(const Printer &rhs) {
  cout << "Printer" << PrintID() << "=" << rhs.PrintID() << endl;
  value_ = rhs.value_;
  return *this;
}

bool Printer::operator<(const Printer &rhs) const {
  cout << "Printer" << PrintID() << "<" << rhs.PrintID() << endl;
  return value_ < rhs.value_;
}

std::string Printer::PrintID(void) const {
  stringstream ss;
  string paren("("), comma(","), closeparen(")");
  ss << paren << id_ << comma << value_ << closeparen;
  return ss.str();
}

std::ostream &operator<<(std::ostream &out, const Printer &rhs) {
  out << "(" << rhs.id_ << "," << rhs.value_ << ")";
  return out;
}

unsigned int Printer::nextid_ = 0;