Solution


/*******************************************************
** Name:        vertexurl.h
** Author:      Leo Liberti
** Source:      GNU C++
** Purpose:     www exploring topologizer - 
**              vertex implementation class (header)
** History:     060820 work started
*******************************************************/

#ifndef _WETVERTEXURLH
#define _WETVERTEXURLH

#include<vector>
#include<string>
#include "vertex.h"
#include "url.h"

class VertexURLException {
 public:
  VertexURLException();
  ~VertexURLException();
};

class VertexURL : public virtual Vertex {
 public:
  VertexURL(int theID, URL* theURLPtr);
  ~VertexURL();

  int getID(void) const;
  int getNumberOfAdjacentVertices(void) const;
  int getAdjacentVertexID(int i) const throw(VertexURLException);
  void addAdjacentVertexID(int ID);
  std::string getText(void);
  URL& getURL(void);

 private:

  int id;
  std::vector<int> star;
  URL* urlPtr;
};

#endif

/*******************************************************
** Name:        vertexurl.cxx
** Author:      Leo Liberti
** Source:      GNU C++
** Purpose:     www exploring topologizer - 
**              vertex implementation class
** History:     060820 work started
*******************************************************/

#include<iostream>
#include "vertexurl.h"

VertexURLException::VertexURLException() { }
VertexURLException::~VertexURLException() { }

VertexURL::VertexURL(int theID, URL* theURLPtr) : 
  id(theID), urlPtr(theURLPtr) { }
VertexURL::~VertexURL() { 
#ifdef DEBUG
  std::cerr << "** destroying VertexURL " << this << std::endl; 
#endif
  delete urlPtr;
}

int VertexURL::getID(void) const {
  return id;
}

int VertexURL::getNumberOfAdjacentVertices(void) const {
  return star.size();
}

int VertexURL::getAdjacentVertexID(int i) const throw(VertexURLException) {
  if (i < 0 || i >= star.size()) {
    throw VertexURLException();
  }
  return star[i];
}

void VertexURL::addAdjacentVertexID(int ID) {
  star.push_back(ID);
}

std::string VertexURL::getText(void) {
  return getURL().getHostName();
}

URL& VertexURL::getURL(void) {
  return *urlPtr;
}



Leo Liberti 2008-01-12